Skip to content

Commit

Permalink
release v2.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
jorisschellekens committed Oct 25, 2022
1 parent 9f456ce commit 9ac59b6
Show file tree
Hide file tree
Showing 2,396 changed files with 1,241 additions and 262 deletions.
Empty file modified .github/ISSUE_TEMPLATE/bug_report.md
100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/feature_request.md
100644 → 100755
Empty file.
Empty file modified .github/workflows/python-publish.yml
100644 → 100755
Empty file.
58 changes: 58 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Test Against Multiple Python Versions

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install test dependencies (gs)
run: |
sudo apt-get -y install ghostscript
- name: Install test dependencies (gTTS)
run: |
pip install gTTS
- name: Install test dependencies (lxml)
run: |
pip install lxml
- name: Install test dependencies (markdown-it-py)
run: |
pip install markdown-it-py
- name: Install test dependencies (matplotlib)
run: |
pip install matplotlib==3.5.3
- name: Install test dependencies (nltk)
run: |
pip install nltk
- name: Install test dependencies (opencv-python)
run: |
pip install opencv-python
- name: Install test dependencies (pandas)
run: |
pip install pandas
- name: Install test dependencies (textblob)
run: |
pip install textblob
- name: Test with pytest
run: |
pytest
- uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: test-artifacts
path: tests/output/
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified BORB_CONTRIBUTOR_LICENSE_AGREEMENT.md
100644 → 100755
Empty file.
Empty file modified CODE_OF_CONDUCT.md
100644 → 100755
Empty file.
Empty file modified CONTRIBUTING.md
100644 → 100755
Empty file.
Empty file modified LICENSE.md
100644 → 100755
Empty file.
Empty file modified MANIFEST.in
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
[![Corpus Coverage : 100.0%](https://img.shields.io/badge/corpus%20coverage-100.0%25-green)]()
[![Text Extraction : 93.1%](https://img.shields.io/badge/text%20extraction-93.1%25-green)]()
[![Public Method Documentation : 100%](https://img.shields.io/badge/public%20method%20documentation-100%25-green)]()
[![Number of Tests : 396](https://img.shields.io/badge/number%20of%20tests-396-green)]()

[![Number of Tests : 414](https://img.shields.io/badge/number%20of%20tests-414-green)]()
[![Python : 3.8 | 3.9 | 3.10 ](https://img.shields.io/badge/python-3.8%20|%203.9%20|%203.10-green)]()

[![Downloads](https://pepy.tech/badge/borb)](https://pepy.tech/project/borb)
[![Downloads](https://pepy.tech/badge/borb/month)](https://pepy.tech/project/borb)
Expand Down
Empty file modified borb/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/datastructure/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/datastructure/disjoint_set.py
100644 → 100755
Empty file.
Empty file modified borb/datastructure/str_trie.py
100644 → 100755
Empty file.
Empty file modified borb/io/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/filter/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/filter/ascii85_decode.py
100644 → 100755
Empty file.
Empty file modified borb/io/filter/flate_decode.py
100644 → 100755
Empty file.
Empty file modified borb/io/filter/lzw_decode.py
100644 → 100755
Empty file.
Empty file modified borb/io/filter/run_length_decode.py
100644 → 100755
Empty file.
Empty file modified borb/io/filter/stream_decode_util.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/any_object_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/encryption/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/encryption/rc4.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/encryption/standard_security_handler.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/font/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/font/font_dictionary_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/function/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/function/function_dictionary_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/image/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/image/ccitt_fax_image_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/image/compressed_jpeg_image_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/image/grayscale_image_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/image/jbig2_image_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/image/jpeg_2000_image_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/image/jpeg_image_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/metadata/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/metadata/xmp_metadata_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/object/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/object/array_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/object/dictionary_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/object/stream_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/page/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/page/page_dictionary_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/page/root_dictionary_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/postfix/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/postfix/postfix_eval.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/primitive/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/primitive/number_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/primitive/string_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/reference/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/reference/reference_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/reference/xref_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/tokenize/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/tokenize/high_level_tokenizer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/tokenize/low_level_tokenizer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/read/types.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/__init__.py
100644 → 100755
Empty file.
6 changes: 4 additions & 2 deletions borb/io/write/any_object_transformer.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
from typing import Optional, Union

from borb.io.read.types import AnyPDFType
from borb.io.write.ascii_art.ascii_art_transformer import ASCIIArtTransformer
from borb.io.write.version.version_as_comment_transformer import (
VersionAsCommentTransformer,
)
from borb.io.write.document.catalog_transformer import CatalogTransformer
from borb.io.write.document.document_transformer import DocumentTransformer
from borb.io.write.document.information_dictionary_transformer import (
Expand Down Expand Up @@ -40,7 +42,7 @@ class AnyObjectTransformer(Transformer):
def __init__(self):
super().__init__()
# fun
self.add_child_transformer(ASCIIArtTransformer())
self.add_child_transformer(VersionAsCommentTransformer())
# special object types
self.add_child_transformer(DocumentTransformer())
self.add_child_transformer(CatalogTransformer())
Expand Down
2 changes: 0 additions & 2 deletions borb/io/write/ascii_art/ascii_logo.txt

This file was deleted.

Empty file modified borb/io/write/conformance_level.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/document/__init__.py
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion borb/io/write/document/catalog_transformer.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def transform(

needs_outputintents: bool = (context is not None
and isinstance(context.root_object, Document)
and context.root_object.get_document_info().get_write_conformance_level() is not None)
and context.root_object.get_document_info().get_conformance_level_upon_create() is not None)
if needs_outputintents:
self._build_rgb_outputintent_dictionary(object_to_transform)
# fmt: on
Expand Down
Empty file modified borb/io/write/document/document_transformer.py
100644 → 100755
Empty file.
9 changes: 6 additions & 3 deletions borb/io/write/document/information_dictionary_transformer.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from borb.io.write.object.dictionary_transformer import DictionaryTransformer
from borb.io.write.object.stream_transformer import StreamTransformer
from borb.io.write.transformer import Transformer, WriteTransformerState
from borb.license.version import Version
from borb.pdf.document.document import Document
from borb.pdf.trailer.document_info import XMPDocumentInfo

Expand Down Expand Up @@ -113,7 +114,9 @@ def _update_info_dictionary(self, info_dictionary: Dictionary) -> Dictionary:
)

# set Producer
info_dictionary[Name("Producer")] = String("borb")
info_dictionary[Name("Producer")] = String(
Version.get_producer() + " " + Version.get_version()
)

return info_dictionary

Expand Down Expand Up @@ -269,12 +272,12 @@ def transform(
and "Trailer" in document["XRef"] \
and "Root" in document["XRef"]["Trailer"] \
and "Metadata" in document["XRef"]["Trailer"]["Root"]
needs_xmp_metadata = has_xmp_metadata or (document.get_document_info().get_write_conformance_level() is not None)
needs_xmp_metadata = has_xmp_metadata or (document.get_document_info().get_conformance_level_upon_create() is not None)
# fmt: on

if needs_xmp_metadata:
conformance_level: ConformanceLevel = (
document.get_document_info().get_write_conformance_level()
document.get_document_info().get_conformance_level_upon_create()
)

# write XMP /Metadata
Expand Down
Empty file modified borb/io/write/document/resources/sRGB_CS_profile.icm
100644 → 100755
Empty file.
Empty file modified borb/io/write/font/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/font/character_set_listener.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/font/copy_command_operator.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/font/subset_show_text_with_glyph_positioning.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/font/subsetter.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/image/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/image/image_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/object/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/object/array_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/object/dictionary_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/object/stream_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/page/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/page/page_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/page/pages_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/primitive/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/primitive/boolean_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/primitive/name_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/primitive/number_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/primitive/string_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/reference/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/reference/reference_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/reference/xref_transformer.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/transformer.py
100644 → 100755
Empty file.
File renamed without changes.
25 changes: 13 additions & 12 deletions .../write/ascii_art/ascii_art_transformer.py → ...version/version_as_comment_transformer.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
"""
This implementation of WriteBaseTransformer is responsible for writing ASCII art in every PDF
"""
from pathlib import Path
import typing
from typing import Optional

from borb.io.read.types import AnyPDFType, Stream
from borb.io.write.transformer import Transformer, WriteTransformerState
from borb.license.version import Version


class ASCIIArtTransformer(Transformer):
class VersionAsCommentTransformer(Transformer):
"""
This implementation of WriteBaseTransformer is responsible for writing ASCII art in every PDF
This implementation of WriteBaseTransformer is responsible for writing the borb version in every PDF
"""

def __init__(self):
Expand Down Expand Up @@ -41,19 +42,19 @@ def transform(
assert isinstance(object_to_transform, Stream)
# fmt: on

f = Path(__file__).parent / "ascii_logo.txt"
with open(f, "r") as logo_file_handle:
ascii_logo = logo_file_handle.readlines()

# append newline (if needed)
if ascii_logo[-1][-1] != "\n":
ascii_logo[-1] += "\n"
# build
version_as_comment_str: typing.List[str] = [
Version.get_producer() + " " + Version.get_version(),
Version.get_author(),
]

# convert to latin1
ascii_logo_bytes = [bytes("% " + x, "utf8") for x in ascii_logo]
version_as_comment_bytes = [
bytes("% " + x + "\n", "utf8") for x in version_as_comment_str
]

self._has_been_used = True
for x in ascii_logo_bytes:
for x in version_as_comment_bytes:
context.destination.write(x)
context.destination.write(bytes("\n", "utf8"))

Expand Down
Empty file modified borb/io/write/xmp/__init__.py
100644 → 100755
Empty file.
Empty file modified borb/io/write/xmp/xmp_transformer.py
100644 → 100755
Empty file.
43 changes: 43 additions & 0 deletions borb/license/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""
This file is part of the borb (R) project.
Copyright (c) 2020-2040 borb Group NV
Authors: Joris Schellekens, et al.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License version 3
as published by the Free Software Foundation with the addition of the
following permission added to Section 15 as permitted in Section 7(a):
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
BORB GROUP. BORB GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
OF THIRD PARTY RIGHTS
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, see http://www.gnu.org/licenses or write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA, 02110-1301 USA.
The interactive user interfaces in modified source and object code versions
of this program must display Appropriate Legal Notices, as required under
Section 5 of the GNU Affero General Public License.
In accordance with Section 7(b) of the GNU Affero General Public License,
a covered work must retain the producer line in every PDF that is created
or manipulated using borb.
You can be released from the requirements of the license by purchasing
a commercial license. Buying such a license is mandatory as soon as you
develop commercial activities involving the borb software without
disclosing the source code of your own applications.
These activities include: offering paid services to customers as an ASP,
serving PDFs on the fly in a web application, shipping borb with a closed
source product.
For more information, please contact borb Software Corp. at this
address: [email protected]
"""
120 changes: 120 additions & 0 deletions borb/license/anonymous_user_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This class is responsible for getting/setting an anonymous (GDPR-compliant) ID
"""
import sysconfig
import typing
from pathlib import Path

from borb.license.uuid import UUID


class AnonymousUserID:
"""
This class is responsible for getting/setting an anonymous (GDPR-compliant) ID
"""

USER_ID_FILE_NAME: str = "anonymous_user_id"

@staticmethod
def _get_borb_installation_dir() -> typing.Optional[Path]:
for path_name in sysconfig.get_path_names():
# check whether the installation path directory exists
installation_path: Path = Path(sysconfig.get_path(path_name))
if not installation_path.exists():
continue
# check whether the borb directory exists
borb_dir: Path = installation_path / "borb"
if borb_dir.exists():
return borb_dir
return None

@staticmethod
def _get_user_id_file_from_borb_dir() -> typing.Optional[Path]:
borb_dir: typing.Optional[Path] = AnonymousUserID._get_borb_installation_dir()
if borb_dir is None:
return None
# check whether the USER_ID_FILE_NAME file exists
user_id_file: Path = borb_dir / AnonymousUserID.USER_ID_FILE_NAME
if user_id_file.exists():
return user_id_file
# return
return None

@staticmethod
def disable() -> None:
"""
This method disables the anonymous user ID.
This clears the hidden file in the borb installation directory.
When this file is empty, an empty user ID is passed in the get function
:return: None
"""
if (
AnonymousUserID._get_borb_installation_dir() is not None
and AnonymousUserID._get_borb_installation_dir().exists()
):
with open(
AnonymousUserID._get_borb_installation_dir()
/ AnonymousUserID.USER_ID_FILE_NAME,
"w",
) as fh:
fh.write("")

@staticmethod
def enable() -> None:
"""
This method enables the anonymous user ID.
This resets the hidden file in the borb installation directory.
When this file is reset, a new user ID is created and passed in the get function
:return: None
"""
if (
AnonymousUserID._get_user_id_file_from_borb_dir() is not None
and AnonymousUserID._get_user_id_file_from_borb_dir().exists()
):
AnonymousUserID._get_user_id_file_from_borb_dir().unlink()
AnonymousUserID.get()

@staticmethod
def get() -> typing.Optional[str]:
"""
This function (creates and then) returns an anonymous user ID.
This ID is stored in a file in the borb installation directory to ensure consistency between calls.
:return: an anonymous user ID
"""
# IF borb installation directory exists, but the file does not exist (yet)
# THEN create the file, return the uuid
if (
AnonymousUserID._get_borb_installation_dir() is not None
and AnonymousUserID._get_borb_installation_dir().exists()
and (
AnonymousUserID._get_user_id_file_from_borb_dir() is None
or not AnonymousUserID._get_user_id_file_from_borb_dir().exists()
)
):
uuid: str = UUID.get()
with open(
AnonymousUserID._get_borb_installation_dir()
/ AnonymousUserID.USER_ID_FILE_NAME,
"w",
) as fh:
fh.write(uuid)
return uuid

# IF the borb installation directory exists, and the user_id file exists
# THEN read the user_id file, and return its content
if (
AnonymousUserID._get_user_id_file_from_borb_dir() is not None
and AnonymousUserID._get_user_id_file_from_borb_dir().exists()
):
uuid: typing.Optional[str] = None
try:
with open(AnonymousUserID._get_user_id_file_from_borb_dir(), "r") as fh:
uuid = fh.read()
except:
pass
return uuid

# default
return None
Loading

0 comments on commit 9ac59b6

Please sign in to comment.