-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f456ce
commit 9ac59b6
Showing
2,396 changed files
with
1,241 additions
and
262 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.