A simple document generator with not very rich functionality that can export a document to some formats such as text, docx, xlsx and markdown.
Project description
Scribber
A simple document generator with not very rich functionality that can export a document to some formats such as text, docx, xlsx and markdown.
Installation
pip install scribber
Usage
from scribber import (
SimpleDocument,
Title,
EmptyLine,
Paragraph,
Table,
Director,
CodeBlock,
DocumentBuilder,
ExcelDocument,
MarkdownDocument,
TextDocument,
WordDocument,
)
CODE_EXAMPLE = """
import platform
def main():
print("Hello World!")
print(f"OS: {platform.system()}")
if __name__ == "__main__":
main()
"""
CODE_RESULT = """Hello World!
OS: Linux"""
if __name__ == "__main__":
# Create abstract document
doc = SimpleDocument()
doc.add(Title(title="Funny report"))
doc.add(EmptyLine())
doc.add(Paragraph(text="Let me show you report"))
doc.add(
Table(
headers=["one", "two", "three", "four"],
content=[
(1, 2, 3, 4),
("234", 345, 986, ""),
(89, 35, 587643, 8675),
],
)
)
doc.extend(
(
EmptyLine(),
Title(title="Code block", level=2),
CodeBlock(style="python", code=CODE_EXAMPLE),
CodeBlock(style="console", code=CODE_RESULT),
Paragraph(text="It's Ok!"),
)
)
director = Director()
text_report_builder = DocumentBuilder(doc=TextDocument())
word_report_builder = DocumentBuilder(doc=WordDocument())
excel_report_builder = DocumentBuilder(doc=ExcelDocument())
markdown_report_builder = DocumentBuilder(doc=MarkdownDocument())
print("Make a Text Document")
director.builder = text_report_builder
director.build_report_from_doc(doc)
text_report_builder.parts.save("test.txt")
print("Make a Word Document")
director.builder = word_report_builder
director.build_report_from_doc(doc)
word_report_builder.parts.save("test.docx")
print("Make a Excel Document")
director.builder = excel_report_builder
director.build_report_from_doc(doc)
excel_report_builder.parts.save("test.xlsx")
print("Make a Markdown Document")
director.builder = markdown_report_builder
director.build_report_from_doc(doc)
markdown_report_builder.parts.save("test.md")
print()
print("Build without Director")
text_report_builder.add_title(Title(title="Next report"))
text_report_builder.add_paragraph(Paragraph(text="That is all!"))
print(text_report_builder.parts.get_result())
The text file example
Funny report
============
Let me show you report
---------------------------
one | two | three | four
---------------------------
1 | 2 | 3 | 4
234 | 345 | 986 |
89 | 35 | 587643 | 8675
---------------------------
Total
=====
It's Ok!
requirements
- lxml>=4.9.1<5.0.0
- pydantic>=1.10.2<2.0.0
- python-docx>=0.8.11<1.0.0
- typing_extensions>=4.4.0<5.0.0
- XlsxWriter>=3.0.3<4.0.0
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 scribber-0.1.19.tar.gz.
File metadata
- Download URL: scribber-0.1.19.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06149d2dd3c9915e9fbbabc5cfc0a1a681e4242b531828183dbe5b7732b8dda4
|
|
| MD5 |
4b555681d59ce88cce597ac2ea93cc84
|
|
| BLAKE2b-256 |
3771b2a30ebde500ac11bc71f3a4159419529627d26d2256bfe1970f1c633d7d
|
File details
Details for the file scribber-0.1.19-py3-none-any.whl.
File metadata
- Download URL: scribber-0.1.19-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
162a5a899bc0c4d257e354f5e9e5615e5b6fbfef20197d8ffe72c6bea3f6b9af
|
|
| MD5 |
00d9f79eee822f1b0029c1bc4b2f67f8
|
|
| BLAKE2b-256 |
6c3d014bba2b7f424c2cda782cc26f5bba646cafbae74040c25df17cde554049
|