Skip to content

Commit

Permalink
Run black and isort on all files
Browse files Browse the repository at this point in the history
  • Loading branch information
JelteF committed Jul 15, 2023
1 parent 0836114 commit 2050b14
Show file tree
Hide file tree
Showing 63 changed files with 1,527 additions and 1,190 deletions.
93 changes: 54 additions & 39 deletions broken_examples/complex_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,33 @@
# begin-doc-include
import os

from pylatex import Document, PageStyle, Head, Foot, MiniPage, \
StandAloneGraphic, MultiColumn, Tabu, LongTabu, LargeText, MediumText, \
LineBreak, NewPage, Tabularx, TextColor, simple_page_number
from pylatex.utils import bold, NoEscape
from pylatex import (
Document,
Foot,
Head,
LargeText,
LineBreak,
LongTabu,
MediumText,
MiniPage,
MultiColumn,
NewPage,
PageStyle,
StandAloneGraphic,
Tabu,
Tabularx,
TextColor,
simple_page_number,
)
from pylatex.utils import NoEscape, bold


def generate_unique():
geometry_options = {
"head": "40pt",
"margin": "0.5in",
"bottom": "0.6in",
"includeheadfoot": True
"includeheadfoot": True,
}
doc = Document(geometry_options=geometry_options)

Expand All @@ -32,55 +47,57 @@ def generate_unique():

# Header image
with first_page.create(Head("L")) as header_left:
with header_left.create(MiniPage(width=NoEscape(r"0.49\textwidth"),
pos='c')) as logo_wrapper:
logo_file = os.path.join(os.path.dirname(__file__),
'sample-logo.png')
logo_wrapper.append(StandAloneGraphic(image_options="width=120px",
filename=logo_file))
with header_left.create(
MiniPage(width=NoEscape(r"0.49\textwidth"), pos="c")
) as logo_wrapper:
logo_file = os.path.join(os.path.dirname(__file__), "sample-logo.png")
logo_wrapper.append(
StandAloneGraphic(image_options="width=120px", filename=logo_file)
)

# Add document title
with first_page.create(Head("R")) as right_header:
with right_header.create(MiniPage(width=NoEscape(r"0.49\textwidth"),
pos='c', align='r')) as title_wrapper:
with right_header.create(
MiniPage(width=NoEscape(r"0.49\textwidth"), pos="c", align="r")
) as title_wrapper:
title_wrapper.append(LargeText(bold("Bank Account Statement")))
title_wrapper.append(LineBreak())
title_wrapper.append(MediumText(bold("Date")))

# Add footer
with first_page.create(Foot("C")) as footer:
message = "Important message please read"
with footer.create(Tabularx(
"X X X X",
width_argument=NoEscape(r"\textwidth"))) as footer_table:

with footer.create(
Tabularx("X X X X", width_argument=NoEscape(r"\textwidth"))
) as footer_table:
footer_table.add_row(
[MultiColumn(4, align='l', data=TextColor("blue", message))])
[MultiColumn(4, align="l", data=TextColor("blue", message))]
)
footer_table.add_hline(color="blue")
footer_table.add_empty_row()

branch_address = MiniPage(
width=NoEscape(r"0.25\textwidth"),
pos='t')
branch_address = MiniPage(width=NoEscape(r"0.25\textwidth"), pos="t")
branch_address.append("960 - 22nd street east")
branch_address.append("\n")
branch_address.append("Saskatoon, SK")

document_details = MiniPage(width=NoEscape(r"0.25\textwidth"),
pos='t', align='r')
document_details = MiniPage(
width=NoEscape(r"0.25\textwidth"), pos="t", align="r"
)
document_details.append("1000")
document_details.append(LineBreak())
document_details.append(simple_page_number())

footer_table.add_row([branch_address, branch_address,
branch_address, document_details])
footer_table.add_row(
[branch_address, branch_address, branch_address, document_details]
)

doc.preamble.append(first_page)
# End first page style

# Add customer information
with doc.create(Tabu("X[l] X[r]")) as first_page_table:
customer = MiniPage(width=NoEscape(r"0.49\textwidth"), pos='h')
customer = MiniPage(width=NoEscape(r"0.49\textwidth"), pos="h")
customer.append("Verna Volcano")
customer.append("\n")
customer.append("For some Person")
Expand All @@ -92,8 +109,7 @@ def generate_unique():
customer.append("Address3")

# Add branch information
branch = MiniPage(width=NoEscape(r"0.49\textwidth"), pos='t!',
align='r')
branch = MiniPage(width=NoEscape(r"0.49\textwidth"), pos="t!", align="r")
branch.append("Branch no.")
branch.append(LineBreak())
branch.append(bold("1181..."))
Expand All @@ -107,15 +123,14 @@ def generate_unique():
doc.add_color(name="lightgray", model="gray", description="0.80")

# Add statement table
with doc.create(LongTabu("X[l] X[2l] X[r] X[r] X[r]",
row_height=1.5)) as data_table:
data_table.add_row(["date",
"description",
"debits($)",
"credits($)",
"balance($)"],
mapper=bold,
color="lightgray")
with doc.create(
LongTabu("X[l] X[2l] X[r] X[r] X[r]", row_height=1.5)
) as data_table:
data_table.add_row(
["date", "description", "debits($)", "credits($)", "balance($)"],
mapper=bold,
color="lightgray",
)
data_table.add_empty_row()
data_table.add_hline()
row = ["2016-JUN-01", "Test", "$100", "$1000", "-$900"]
Expand All @@ -129,12 +144,12 @@ def generate_unique():

# Add cheque images
with doc.create(LongTabu("X[c] X[c]")) as cheque_table:
cheque_file = os.path.join(os.path.dirname(__file__),
'chequeexample.png')
cheque_file = os.path.join(os.path.dirname(__file__), "chequeexample.png")
cheque = StandAloneGraphic(cheque_file, image_options="width=200px")
for i in range(0, 20):
cheque_table.add_row([cheque, cheque])

doc.generate_pdf("complex_report", clean_tex=False)


generate_unique()
8 changes: 4 additions & 4 deletions broken_examples/longtabu.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

# begin-doc-include
from pylatex import Document, LongTabu, HFill
from pylatex import Document, HFill, LongTabu
from pylatex.utils import bold


Expand All @@ -19,7 +19,7 @@ def genenerate_longtabu():
"margin": "0.5in",
"headheight": "20pt",
"headsep": "10pt",
"includeheadfoot": True
"includeheadfoot": True,
}
doc = Document(page_numbers=True, geometry_options=geometry_options)

Expand All @@ -30,8 +30,7 @@ def genenerate_longtabu():
data_table.add_hline()
data_table.add_empty_row()
data_table.end_table_header()
data_table.add_row(["Prov", "Num", "CurBal", "IntPay", "Total",
"IntR"])
data_table.add_row(["Prov", "Num", "CurBal", "IntPay", "Total", "IntR"])
row = ["PA", "9", "$100", "%10", "$1000", "Test"]
for i in range(50):
data_table.add_row(row)
Expand All @@ -42,4 +41,5 @@ def genenerate_longtabu():

doc.generate_pdf("longtabu", clean_tex=False)


genenerate_longtabu()
9 changes: 5 additions & 4 deletions broken_examples/tabus.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

# begin-doc-include
from random import randint
from pylatex import Document, LongTabu, Tabu, Center

from pylatex import Center, Document, LongTabu, Tabu
from pylatex.utils import bold


Expand All @@ -18,7 +19,7 @@ def genenerate_tabus():
"margin": "1.5in",
"headheight": "20pt",
"headsep": "10pt",
"includeheadfoot": True
"includeheadfoot": True,
}
doc = Document(page_numbers=True, geometry_options=geometry_options)

Expand All @@ -30,8 +31,7 @@ def genenerate_tabus():
data_table.add_hline()
data_table.add_empty_row()
data_table.end_table_header()
data_table.add_row(["Prov", "Num", "CurBal", "IntPay", "Total",
"IntR"])
data_table.add_row(["Prov", "Num", "CurBal", "IntPay", "Total", "IntR"])
row = ["PA", "9", "$100", "%10", "$1000", "Test"]
for i in range(40):
data_table.add_row(row)
Expand All @@ -56,4 +56,5 @@ def genenerate_tabus():

doc.generate_pdf("tabus", clean_tex=False)


genenerate_tabus()
8 changes: 4 additions & 4 deletions docs/gen_example_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

title = sys.argv[1]

if title.endswith('_ex'):
if title.endswith("_ex"):
title = title[:-3]

title = title.replace('_', ' ')
title = title.capitalize() + ' example'
title = title.replace("_", " ")
title = title.capitalize() + " example"

print(title)
print(len(title) * '=')
print(len(title) * "=")
Loading

0 comments on commit 2050b14

Please sign in to comment.