Skip to content

Commit

Permalink
Merge pull request #46 from barseghyanartur/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
barseghyanartur authored Oct 9, 2023
2 parents b949637 + b334b14 commit 68baba4
Show file tree
Hide file tree
Showing 149 changed files with 3,831 additions and 2,305 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ jobs:
steps:
- name: Install wkhtmltopdf
run: sudo apt-get update && sudo apt-get install -y wkhtmltopdf libpango-1.0-0 libharfbuzz0b libpangoft2-1.0-0 poppler-utils
- name: Clean-up
run: sudo apt clean && sudo apt autoclean && sudo rm -rf /tmp/* && sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down Expand Up @@ -105,6 +107,8 @@ jobs:
steps:
- name: Install wkhtmltopdf
run: sudo apt-get update && sudo apt-get install -y wkhtmltopdf libpango-1.0-0 libharfbuzz0b libpangoft2-1.0-0 poppler-utils
- name: Clean-up
run: sudo apt clean && sudo apt autoclean && sudo rm -rf /tmp/* && sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down Expand Up @@ -159,6 +163,8 @@ jobs:
steps:
- name: Install wkhtmltopdf
run: sudo apt-get update && sudo apt-get install -y wkhtmltopdf libpango-1.0-0 libharfbuzz0b libpangoft2-1.0-0 poppler-utils
- name: Clean-up
run: sudo apt clean && sudo apt autoclean && sudo rm -rf /tmp/* && sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down
11 changes: 10 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ Release history and notes
.. _Armenian genocide: https://en.wikipedia.org/wiki/Armenian_genocide
.. _Blockade of the Republic of Artsakh: https://en.wikipedia.org/wiki/Blockade_of_the_Republic_of_Artsakh_(2022%E2%80%93present)
.. _Pillow: https://pypi.org/project/pillow/
.. _WeasyPrint: https://pypi.org/project/weasyprint/
.. _imgkit: https://pypi.org/project/imgkit/
.. _pdf2image: https://pypi.org/project/pdf2image/
.. _pdfkit: https://pypi.org/project/pdfkit/
.. _Pillow: https://pypi.org/project/pillow/
.. _reportlab: https://pypi.org/project/reportlab/
.. _wkhtmltopdf: https://wkhtmltopdf.org/

`Sequence based identifiers
<http://en.wikipedia.org/wiki/Software_versioning#Sequence-based_identifiers>`_
Expand All @@ -26,6 +27,14 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.

0.17.9
------
2023-10-10

- Improvements and fixes in the documentation.
- Announcing feature plans to change default PDF and Image generators
to `Pillow`_ based ones, instead of `wkhtmltopdf`_ in version 0.18.

0.17.8
------
2023-09-21
Expand Down
177 changes: 177 additions & 0 deletions docs/_static/css/prism_sphinx_rtd_theme.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
/**
* Python Sphinx RTD theme for PrismJs.
*
* The original sphinx-rtd-theme (https://github.com/readthedocs/sphinx_rtd_theme).
*
* Adapted from PrismJS prism-themes (https://github.com/PrismJS/prism-themes),
* specifically prism-gruvbox-light.css theme.
*
* @author Artur Barseghyan (https://github.com/barseghyanartur)
* @version 1.0
*/

code[class*="language-"],
pre[class*="language-"] {
color: #3c3836;
font-family: Consolas, Monaco, "Andale Mono", monospace;
direction: ltr;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}

pre[class*="language-"]::-moz-selection,
pre[class*="language-"] ::-moz-selection,
code[class*="language-"]::-moz-selection,
code[class*="language-"] ::-moz-selection {
color: #282828;
background: #a89984;
}

pre[class*="language-"]::selection,
pre[class*="language-"] ::selection,
code[class*="language-"]::selection,
code[class*="language-"] ::selection {
color: #282828;
background: #a89984;
}

/* Code blocks */
pre[class*="language-"] {
padding: 1em;
margin: 0.5em 0;
overflow: auto;
}

:not(pre) > code[class*="language-"],
pre[class*="language-"] {
background: #eeffcc;
border: none !important;
box-shadow: none !important;
}

/* Inline code */
:not(pre) > code[class*="language-"] {
padding: 0.1em;
border-radius: 0.3em;
}

.token.comment {
font-style: italic;
}

.token.comment,
.token.prolog,
.token.cdata {
color: #7c6f64;
}

.token.keyword {
color: #007020;
font-weight: bold;
}

.token.delimiter,
.token.boolean,
.token.selector,
.token.important,
.token.atrule {
color: #9d0006;
}

.token.operator,
.token.punctuation,
.token.attr-name {
color: #7c6f64;
background-color: #eeffcc;
}

.token.tag,
.token.tag .punctuation,
.token.doctype,
.token.builtin {
color: #b57614;
}

.token.entity,
.token.number,
.token.symbol {
color: #8f3f71;
}

.token.property,
.token.constant,
.token.variable {
color: #9d0006;
}

.token.string {
color: #4070a0;
}

.token.char {
color: #797403;
}

.token.attr-value,
.token.attr-value .punctuation {
color: #7c6f64;
}

.token.url {
color: #797403;
text-decoration: underline;
}

.token.function {
color: #b57614;
}

.token.regex {
background: #797403;
}

.token.bold {
font-weight: bold;
}

.token.italic {
font-style: italic;
}

.token.inserted {
background: #7c6f64;
}

.token.deleted {
background: #9d0006;
}

/* Additional overrides */
.rst-content code,
.rst-content tt,
code {
border: none;
}

pre[class*="language-"] {
border: 1px solid #e1e4e5!important;
}
code[class*="language-"],
pre[class*="language-"] {
font-size: 12px;
}

pre[class*="language-"] > code:first-child {
margin: 0!important;
padding: 0!important;
}
9 changes: 9 additions & 0 deletions docs/_static/examples/creating_docx/docx_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Required imports
from faker import Faker
from faker_file.providers.docx_file import DocxFileProvider

FAKER = Faker() # Initialize Faker
FAKER.add_provider(DocxFileProvider) # Register DocxFileProvider

# Generate DOCX file
docx_file = FAKER.docx_file()
9 changes: 9 additions & 0 deletions docs/_static/examples/creating_docx/docx_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Required imports
from faker import Faker
from faker_file.providers.docx_file import DocxFileProvider

FAKER = Faker() # Initialize Faker
FAKER.add_provider(DocxFileProvider) # Register DocxFileProvider

# Generate DOCX file of 20,000 characters
docx_file = FAKER.docx_file(max_nb_chars=20_000)
9 changes: 9 additions & 0 deletions docs/_static/examples/creating_docx/docx_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Required imports
from faker import Faker
from faker_file.providers.docx_file import DocxFileProvider

FAKER = Faker() # Initialize Faker
FAKER.add_provider(DocxFileProvider) # Register DocxFileProvider

# Generate DOCX file, wrapping each line after 80 characters
docx_file = FAKER.docx_file(wrap_chars_after=80)
47 changes: 47 additions & 0 deletions docs/_static/examples/creating_docx/docx_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Required imports
from faker import Faker
from faker_file.base import DynamicTemplate
from faker_file.contrib.docx_file import (
add_page_break,
add_paragraph,
add_picture,
add_table,
)
from faker_file.providers.docx_file import DocxFileProvider

FAKER = Faker() # Initialize Faker
FAKER.add_provider(DocxFileProvider) # Register DocxFileProvider

# Create a DOCX file with paragraph, picture, table and manual page breaks
# in between the mentioned elements. The ``DynamicTemplate`` simply
# accepts a list of callables (such as ``add_paragraph``,
# ``add_page_break``) and dictionary to be later on fed to the callables
# as keyword arguments for customising the default values.
docx_file = FAKER.docx_file(
content=DynamicTemplate(
[
(add_paragraph, {}), # Add paragraph
(add_page_break, {}), # Add page break
(add_picture, {}), # Add picture
(add_page_break, {}), # Add page break
(add_table, {}), # Add table
(add_page_break, {}), # Add page break
]
)
)

# You could make the list as long as you like or simply multiply for
# easier repetition as follows:
docx_file = FAKER.docx_file(
content=DynamicTemplate(
[
(add_paragraph, {}), # Add paragraph
(add_page_break, {}), # Add page break
(add_picture, {}), # Add picture
(add_page_break, {}), # Add page break
(add_table, {}), # Add table
(add_page_break, {}), # Add page break
]
* 5 # Will repeat your config 5 times
)
)
60 changes: 60 additions & 0 deletions docs/_static/examples/creating_images/augment_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from faker import Faker
from faker_file.providers.augment_image_from_path import (
AugmentImageFromPathProvider,
)
from faker_file.providers.augment_random_image_from_dir import (
AugmentRandomImageFromDirProvider,
)
from faker_file.providers.image.augment import (
add_brightness,
decrease_contrast,
flip_horizontal,
flip_vertical,
resize_height,
resize_width,
)
from faker_file.providers.png_file import GraphicPngFileProvider

FAKER = Faker()
FAKER.add_provider(AugmentImageFromPathProvider)
FAKER.add_provider(AugmentRandomImageFromDirProvider)
FAKER.add_provider(GraphicPngFileProvider)

# Create a couple of graphic images to augment later on.
FAKER.graphic_png_file(basename="01") # One named 01.png
# And 5 more with random names.
for __ in range(5):
FAKER.graphic_png_file()

# We assumed that directory "/tmp/tmp/" exists and contains
# image files, among which "01.png". Augmentations will be applied
# sequentially, one by one until all fulfilled. If you wish to apply only
# a random number of augmentations, but not all, pass the `num_steps`
# argument, with value less than the number of `augmentations` provided.
augmented_image_file = FAKER.augment_image_from_path(
path="/tmp/tmp/01.png",
augmentations=[
(flip_horizontal, {}),
(flip_vertical, {}),
(decrease_contrast, {}),
(add_brightness, {}),
(resize_width, {"lower": 0.9, "upper": 1.1}),
(resize_height, {"lower": 0.9, "upper": 1.1}),
],
prefix="augmented_image_01_",
# num_steps=3,
)

augmented_random_image_file = FAKER.augment_random_image_from_dir(
source_dir_path="/tmp/tmp/",
augmentations=[
(flip_horizontal, {}),
(flip_vertical, {}),
(decrease_contrast, {}),
(add_brightness, {}),
(resize_width, {"lower": 0.9, "upper": 1.1}),
(resize_height, {"lower": 0.9, "upper": 1.1}),
],
prefix="augmented_random_image_",
# num_steps=3,
)
9 changes: 9 additions & 0 deletions docs/_static/examples/creating_images/imgkit_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from faker import Faker
from faker_file.providers.image.imgkit_generator import ImgkitImageGenerator
from faker_file.providers.png_file import PngFileProvider

FAKER = Faker() # Initialize Faker
FAKER.add_provider(PngFileProvider) # Register PngFileProvider

# Generate PNG file using `imgkit`
pdf_file = FAKER.png_file(image_generator_cls=ImgkitImageGenerator)
11 changes: 11 additions & 0 deletions docs/_static/examples/creating_images/imgkit_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from faker import Faker
from faker_file.providers.image.imgkit_generator import ImgkitImageGenerator
from faker_file.providers.png_file import PngFileProvider

FAKER = Faker() # Initialize Faker
FAKER.add_provider(PngFileProvider) # Register PngFileProvider

# Generate an image file, wrapping each line after 80 characters
png_file = FAKER.png_file(
image_generator_cls=ImgkitImageGenerator, wrap_chars_after=80
)
Loading

0 comments on commit 68baba4

Please sign in to comment.