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
25 changes: 25 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ on:
tags:
- "rel/*.*.*"
- "rel/*.*.*.*"
workflow_dispatch:
inputs:
tag_name:
description: 'Release Tag name for creating Github Release'
required: false
type: string

jobs:
build-n-publish:
Expand Down Expand Up @@ -43,10 +49,29 @@ jobs:
password: ${{ secrets.PYPI_API_TOKEN }} # This token should be created in Settings > Secrets > Actions
# repository_url: https://test.pypi.org/legacy/ # Use this for testing to upload the distribution to test.pypi

- name: Determine tag
id: tag
run: |
TAG_NAME=""
if [[ "${{ github.event.inputs.tag_name }}" != "" ]]; then
TAG_NAME="${{ github.event.inputs.tag_name }}"
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
TAG_NAME="${GITHUB_REF#refs/tags/}"
fi

if [[ -z "$TAG_NAME" ]]; then
echo "No valid tag provided. Skipping release."
exit 0
else
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
fi

- name: Create/Update GitHub Release
id: create_update_release
if: env.TAG_NAME != ''
uses: ncipollo/release-action@v1
with:
tag: ${{ env.TAG_NAME }}
allowUpdates: true
omitNameDuringUpdate: true
makeLatest: true
Expand Down
24 changes: 14 additions & 10 deletions config/robotframework_aio/release_items_JsonPreprocessor.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,25 +178,29 @@
],
"0.14.1.;0.15.0." : [
"
* Allowed users define a naming convention rule key names within JSONP content processed by the **JsonPreprocessor**
**Updated naming convention check**

The input parameter ``keyPattern`` is used to define the key name pattern and the ``keyPattern`` is set by users
The **JsonPreprocessor** supports a user-defined convention for key names. This is enforced using a regex pattern
passed to the constructor of the **JsonPreprocessor** class.

**Example:**
*Example*

| ``json_preprocessor = CJsonPreprocessor()``
Assuming key names may only contain letters, digits and underscores, but must start with a letter, then the **JsonPreprocessor**
has to be initialized in this way:

The ``keyPattern`` is not set when initialized ``CJsonPreprocessor``, the naming convention check is not acitve.
| ``json_preprocessor = CJsonPreprocessor(keyPattern=r'^\\p{L}[\\p{L}\\p{Nd}_]*$')``

| ``json_preprocessor = CJsonPreprocessor(keyPattern=r'^[\\p{L}][\\p{L}0-9]*$')``
This feature is an option. If the user does not define the parameter ``keyPattern``, key names can contain any characters (but cannot be empty).

The ``keyPattern`` is set ``'^[\\p{L}][\\p{L}0-9]*$'`` means key names in the JONP file have to start with characters and following by characters or numbers.
*Example*

* Replaced ``re`` package by ``regex`` package to handle regular expression.
| ``json_preprocessor = CJsonPreprocessor()``

* Improved and aligned error messages
**Maintenance**

* Added and updated the Selftest according to the changes
* Replaced ``re`` package by ``regex`` package to handle extended regular expressions
* Improved and aligned error messages
* Added and updated the self test according to the changed features
"
]
}
Expand Down
32 changes: 32 additions & 0 deletions packagedoc/additional_docs/Description.tex
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,38 @@ \section{How to execute}
In chapter \hyperref[thejsonpformat]{The JSONP format} the format of JSON files used by the \pkg, is described in detail.
All discussed JSON files can be tested with the example script listed above.

% --------------------------------------------------------------------------------------------------------------

\newpage

\section{User defined naming convention}

By default, key names in JSON files can contain any characters (but cannot be empty). But it might be required to limit the character set.
For this purpose the \pkg\ supports an optional user-defined convention for key names. This is enforced using a \pcode{regex} pattern
passed to the constructor of the \pkg\ class.

Assuming key names may only contain letters, digits and underscores, but must start with a letter, then the \pkg\ has to be initialized
in this way:

\begin{pythoncode}[linebackgroundcolor=\hlcode{3,5}]
from JsonPreprocessor.CJsonPreprocessor import CJsonPreprocessor
import pprint
import regex

json_preprocessor = CJsonPreprocessor(keyPattern=r'^\p{L}[\p{L}\p{Nd}_]*$'))
try:
values = json_preprocessor.jsonLoad("./file.jsonp")
pprint.pprint(values)
except Exception as reason:
print(f"'{reason}'")
\end{pythoncode}

The regular expressions \pcode{\\p\{L\}} and \pcode{\\p\{Nd\}} are provided by the \pcode{regex} module:

\begin{itemize}
\item \pcode{\\p\{L\}} matches all Unicode characters classified as \textbf{letter}
\item \pcode{\\p\{Nd\}} matches all Unicode characters classified as \textbf{decimal digit}
\end{itemize}

% --------------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion packagedoc/additional_docs/History.tex
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
\historychange{- Fixed bugs, updated error messages, and improved composite data structure handling}

\historyversiondate{0.9.0}{03/2025}
\historychange{- Allowed users define a naming convention rule key names\newline
\historychange{- Added support of a user-defined convention for key names\newline
- Improved and aligned error messages\newline
- Fixed bugs and updated the Selftest according to the changes}

Expand Down
2 changes: 1 addition & 1 deletion packagedoc/additional_docs/Introduction.tex
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
These deviations harm the syntax highlighting of editors and also cause invalid findings of JSON format related static code checkers.

To avoid conflicts between the standard JSON format and the extended JSON format described here, the \pkg\ uses the alternative file extension
\pcode{.jsonp} for all JSON files.
\pcode{.jsonp} for all JSON files of extended format.

\newpage

Expand Down
14 changes: 0 additions & 14 deletions packagedoc/additional_docs/The JSONP format.tex
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,6 @@ \section{Comments}
{'testlist': ['A1', 'D4']}
\end{pythonlog}

\vspace{2ex}

\section{Naming convention}

All key names in JSONP files must adhere to the following rules:

\begin{itemize}
\item Key names can only consist of letters, digits and the following special characters: \pcode{_ + - * / \\\\ @}
(\textit{backslashes are allowed but have to be masked}).
\item Key names have to start with a letter, a digit or an underscore.
\item Key names must not be empty strings. But leading and trailing blanks will be removed (and therefore do not cause errors).
Also blanks in between allowed characters are not allowed.
\end{itemize}

% --------------------------------------------------------------------------------------------------------------

\newpage
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pypandoc
GenPackageDoc
PythonExtensionsCollection
pydotdict
regex