Skip to content

Commit 9040444

Browse files
committed
fix: Update for running with Python v3.9 or higher and corrections of documentation and minor inconsistencies
1 parent 1979c19 commit 9040444

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

tool-support/bnf_grammar_tools/README.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Instructions on how to export a selected version of the specification from View
2222

2323
=== Install the Python Environment
2424

25-
Ensure that Python version 3.8 or higher is installed on your machine. The most convenient way is to use the https://www.jetbrains.com/pycharm/[PyCharm] tool. Create a dedicated `conda` or `venv` development environment and activate it. The best tool to install a Python base environment is https://github.com/conda-forge/miniforge[miniforge].
25+
Ensure that Python version 3.9 or higher is installed on your machine. The most convenient way is to use the https://www.jetbrains.com/pycharm/[PyCharm] tool. Create a dedicated `conda` or `venv` development environment and activate it. The best tool to install a Python base environment is https://github.com/conda-forge/miniforge[miniforge].
2626

2727
After installation check the active Python version, e.g.:
2828

@@ -35,6 +35,7 @@ After installation check the active Python version, e.g.:
3535
Also ensure that the latest version of the following packages are installed. You can use `pip` or `conda` or `mamba`.
3636

3737
* Package https://pypi.org/project/beautifulsoup4/[beautifulsoup4] is used to parse the HTML input file.
38+
* Package https://pypi.org/project/lxml/[lxml] is used to assist beautifulsoup4 with processing SVG/XML files.
3839
* Package https://pypi.org/project/lark/[lark] is used to parse and verify the extracted BNF source.
3940
* Package https://pypi.org/project/pytest/[pytest] is used to run unit tests.
4041

@@ -43,6 +44,7 @@ for example with the following commands:
4344
[source,shell]
4445
----
4546
$ pip install beautifulsoup4
47+
$ pip install lxml
4648
$ pip install lark
4749
$ pip install pytest
4850
----

tool-support/bnf_grammar_tools/bnf_grammar/bnf_grammar_processor.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
@author: Hans Peter de Koning (DEKonsult)
1313
1414
Requirements:
15-
This tool requires installation of the following packages:
15+
This tool requires Python v3.9 or higher and installation of the following packages:
1616
- beautifulsoup4 (See https://pypi.org/project/beautifulsoup4/)
17+
- lxml (See https://pypi.org/project/lxml/)
1718
- lark (See https://pypi.org/project/lark)
1819
"""
1920

@@ -28,12 +29,11 @@
2829
from enum import Enum, auto
2930
from logging import Logger
3031
from textwrap import wrap
31-
from types import NoneType
3232
from typing import Any, ClassVar, Iterable, Optional
3333

34-
from bs4 import BeautifulSoup, Tag, PageElement, NavigableString
34+
from bs4 import BeautifulSoup, Tag, PageElement
3535

36-
from lark import Lark, Transformer, Tree, UnexpectedInput
36+
from lark import Lark, UnexpectedInput
3737

3838
# Create logger for diagnostic messages at debug, info, warning, error and critical levels
3939
import logging
@@ -661,7 +661,7 @@ def extract_bnf_from_spec(self, input_dir: str, output_dir: str, input_file: str
661661
elif tag.name == "ol" and inside_bnf_clause and contains_pre_tag and tag.parent.name != "li":
662662
LOGGER.debug(f"note <ol> tag={tag}")
663663
list_item_count = 0
664-
note_list = NoteList(clause_id, [], [])
664+
note_list = NoteList(clause_id, [], "")
665665

666666
# Update the contents of <ol> within the HTML tree
667667
self.cleanup_note_html(tag)
@@ -1225,7 +1225,7 @@ def is_lower_kebab_case(text: str) -> bool:
12251225

12261226
def render_nested_lists(html_snippet: str, mode: RenderMode, apply_line_comment: bool) -> str:
12271227
"""
1228-
Return
1228+
Return nested note lists, rendered as comments in HTML or TXT format.
12291229
12301230
:param html_snippet: string in HTML format that contains nested ol and/or ul lists
12311231
:param mode: output render mode
@@ -1386,6 +1386,7 @@ def main() -> None:
13861386
args = parser.parse_args()
13871387
LOGGER.debug(f"args={args}")
13881388
LOGGER.debug(f"bnf_grammar_processor started in {os.getcwd()}")
1389+
LOGGER.info(f"Running Python {sys.version}")
13891390

13901391
input_dir = args.input_dir
13911392
output_dir = args.output_dir

0 commit comments

Comments
 (0)