Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 88
3 changes: 1 addition & 2 deletions .github/workflows/delete-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Delete merged branch
run: gh branch delete ${{ github.head_ref }}
run: gh api -X DELETE repos/${{ github.repository }}/git/refs/heads/${{ github.head_ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

110 changes: 0 additions & 110 deletions .github/workflows/dev.yml

This file was deleted.

113 changes: 0 additions & 113 deletions .github/workflows/prod.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/psf/black
rev: 25.9.0
hooks:
- id: black

- repo: https://github.com/pycqa/isort
rev: 6.1.0
hooks:
- id: isort

- repo: https://github.com/pycqa/flake8
rev: 7.3.0
hooks:
- id: flake8

- repo: https://github.com/pycqa/pylint
rev: v3.3.9
hooks:
- id: pylint
args: [--rcfile=.pylintrc]
8 changes: 6 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ indent-after-paren=4
indent-string=' '

# Maximum number of characters on a single line.
max-line-length=100
max-line-length=88

# Maximum number of lines in a module.
max-module-lines=1000
Expand Down Expand Up @@ -430,7 +430,11 @@ disable=raw-checker-failed,
deprecated-pragma,
use-symbolic-message-instead,
use-implicit-booleaness-not-comparison-to-string,
use-implicit-booleaness-not-comparison-to-zero
use-implicit-booleaness-not-comparison-to-zero,
missing-module-docstring,
attribute-defined-outside-init,
too-few-public-methods,
import-error

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
12 changes: 12 additions & 0 deletions pyloremgen/generator/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from .lorem_pdf import PDFGenerator
from .lorem_text import LoremIpsum, LoremIpsumError
from .pdf_utils.cover_page_template import CoverPageBuilder
from .pdf_utils.pdf_page_settings import PagesConfigPDF

__all__ = [
"LoremIpsum",
"PDFGenerator",
"LoremIpsumError",
"PagesConfigPDF",
"CoverPageBuilder",
]
40 changes: 35 additions & 5 deletions pyloremgen/generator/lorem_pdf.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,47 @@
from typing import Optional

from reportlab.lib.styles import getSampleStyleSheet
from reportlab.platypus import PageBreak, Paragraph

from pyloremgen.generator.lorem_text import LoremIpsum
from pyloremgen.generator.pdf_utils.cover_page_template import CoverPageBuilder
from pyloremgen.generator.pdf_utils.pdf_page_settings import PagesConfigPDF
from .lorem_text import LoremIpsum
from .pdf_utils.cover_page_template import CoverPageBuilder
from .pdf_utils.pdf_page_settings import PagesConfigPDF


class PDFGenerator:
def __init__(self, pages_config=None):
"""
PDFGenerator class for creating PDF documents with Lorem Ipsum content.

This class provides functionality to generate
PDF files filled with Lorem Ipsum text,
with options for customizing page settings and including cover pages.

Attributes:
pages_config (PagesConfigPDF): Configuration for PDF page settings.
lorem (LoremIpsum): Instance of LoremIpsum for generating text content.

Methods:
generate_pdf(filename: str, num_pages: int = 1,
cover_page_count: bool = True) -> None:
Generates a PDF document with the specified number of pages.
"""

def __init__(self, pages_config: Optional[PagesConfigPDF] = None) -> None:
self.pages_config = pages_config or PagesConfigPDF()
self.lorem = LoremIpsum()

def generate_pdf(self, filename, num_pages=1, cover_page_count=True):
def generate_pdf(
self, filename: str, num_pages: int = 1, cover_page_count: bool = True
) -> None:
"""
Generate a PDF document with Lorem Ipsum content.

Args:
filename (str): The name of the output PDF file.
num_pages (int, optional): The number of pages to generate. Defaults to 1.
cover_page_count (bool, optional):
Whether to include a cover page. Defaults to True.
"""
self.num_pages = num_pages
doc = self.pages_config.create_document(filename)
content = []
Expand Down
Loading
Loading