Skip to content

Commit

Permalink
Removed objdictgen and objdictedit cmd-line tools and wx (#24)
Browse files Browse the repository at this point in the history
* Removed objdictgen and objdictedit cmd-line tools
* Removed default dependency to wx, opt-in via [ui]
* README.md update
* Updated tests
  • Loading branch information
sveinse authored May 16, 2024
1 parent b7fbdc3 commit d2cb865
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 144 deletions.
50 changes: 26 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ communication protocol.

This repo is located:

> https://github.com/laerdal/python-objdictgen
> https://github.com/Laerdal/python-objdictgen
objdictgen includes tools to generate c code that works in tandem with a
canfestival library. This tool has been built to work together with the
Laerdal Medical fork for the canfestival library:

> https://github.com/laerdal/canfestival-laerdal
> https://github.com/Laerdal/canfestival-laerdal
objdictgen is a tool to parse, view and manipulate files containing object
dictionary (OD). An object dictionary is entries with data and configuration
Expand All @@ -22,35 +22,21 @@ reading and writing OD files in `.json` format, in legacy XML `.od` and `.eds`
files. It can generate c code for use with the canfestival library.


## Motivation

The biggest improvement with the new tool over the original implementation is
the introduction of a new `.json` based format to store the object dictionary.
The JSON format is well-known and easy to read. The tool supports jsonc,
allowing comments in the json file. `odg` will process the file in a repeatable
manner, making it possible support diffing of the `.json` file output. `odg`
remains 100% compatible with the legacy `.od` format on both input and output.

The original objdictedit and objdictgen tool were written in legacy python2 and
and this is a port to python3.

This tool is a fork from upstream canfestival-3-asc repo:

> https://github.com/laerdal/canfestival-3-asc

## Install

To install into a virtual environment `venv`. Check out this repo and go to
the top in a command-prompt (here assuming Windows and git bash):

$ py -3 -mvenv venv
$ venv/Scripts/python -mpip install --upgrade pip wheel setuptools
$ venv/Scripts/pip install .
$ venv/Scripts/pip install .[ui] # [ui] will install GUI tools

After this `venv/Scripts/odg.exe` (on Windows) will exist and can be called
from anywhere to run it.

The `[ui]` suffix to `pip install` will install the wx dependency needed
for the UI `odg edit`. If no UI is needed, this suffix can be omitted.

## `odg` command-line tool

`odg` is a command-line tool which is installed when the python package
Expand All @@ -72,8 +58,8 @@ The most useful commands are:

### Legacy commands

The legacy commands `objdictgen` and `objdictedit` are still available. The
same commands are available under `odg gen` and `odg edit` respectively.
The legacy commands `objdictgen` and `objdictedit` are no longer available. The
commands are available under `odg gen` and `odg edit` respectively.


## JSON schema
Expand All @@ -100,7 +86,6 @@ descriptions, help with values and validate the file.
}
```


## Conversion

The recommended way to convert existing/legacy `.od` files to the new JSON
Expand All @@ -114,6 +99,23 @@ parameters. The `--drop-unused` will remove any unused *profile* and *DS-302*
parameter that might be used in the file.


## Motivation

The biggest improvement with the new tool over the original implementation is
the introduction of a new `.json` based format to store the object dictionary.
The JSON format is well-known and easy to read. The tool supports jsonc,
allowing comments in the json file. `odg` will process the file in a repeatable
manner, making it possible support diffing of the `.json` file output. `odg`
remains 100% compatible with the legacy `.od` format on both input and output.

The original objdictedit and objdictgen tool were written in legacy python 2 and
and this is a port to python 3.

This tool is a fork from upstream canfestival-3-asc repo:

> https://github.com/Laerdal/canfestival-3-asc

## License

Objdictgen has been based on the python tool included in CanFestival. This
Expand All @@ -123,4 +125,4 @@ original work from CanFestival is:

The Python 3 port and tool improvements have been implemented under

Copyright (C) 2022-2023 Svein Seldal, Laerdal Medical AS
Copyright (C) 2022-2024 Svein Seldal, Laerdal Medical AS
6 changes: 2 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ install_requires =
jsonschema
colorama
deepdiff
wxPython

[options.packages.find]
where = src
Expand All @@ -44,6 +43,8 @@ objdictgen.img = *
objdictgen.schema = *.json

[options.extras_require]
ui =
wxPython
dist =
build
dev =
Expand All @@ -61,6 +62,3 @@ dev =
[options.entry_points]
console_scripts =
odg = objdictgen.__main__:main
objdictgen = objdictgen.__main__:main_objdictgen
objdictedit = objdictgen.__main__:main_objdictedit

45 changes: 0 additions & 45 deletions src/objdictgen/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,51 +424,6 @@ def main(debugopts: DebugOpts, args: Sequence[str]|None = None):
parser.error(f"Programming error: Uknown option '{opts.command}'")


def main_objdictgen():
""" Legacy objdictgen command """

def usage():
print("\nUsage of objdictgen :")
print(f"\n {sys.argv[0]} XMLFilePath CFilePath\n")

try:
opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
except getopt.GetoptError:
# print help information and exit:
usage()
sys.exit(2)

for opt, _ in opts:
if opt in ("-h", "--help"):
usage()
sys.exit()

filein = ""
fileout = ""
if len(args) == 2:
filein = args[0]
fileout = args[1]
else:
usage()
sys.exit()

if filein != "" and fileout != "":
print("Parsing input file", filein)
node = objdictgen.LoadFile(filein)
print("Writing output file", fileout)
node.DumpFile(fileout, filetype='c')
print("All done")


def main_objdictedit():
""" Legacy objdictedit command """

# Import here to prevent including optional UI components for cmd-line use
from .ui.objdictedit import \
main as _main # pylint: disable=import-outside-toplevel
_main()


# To support -m objdictgen
if __name__ == '__main__':
# pylint: disable=no-value-for-parameter
Expand Down
24 changes: 12 additions & 12 deletions tests/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ def test_import_nosis():
def test_import_typing():
import objdictgen.typing

def test_import_ui_commondialogs():
import objdictgen.ui.commondialogs
# def test_import_ui_commondialogs():
# import objdictgen.ui.commondialogs

def test_import_ui_exception():
import objdictgen.ui.exception
# def test_import_ui_exception():
# import objdictgen.ui.exception

def test_import_ui_networkedit():
import objdictgen.ui.networkedit
# def test_import_ui_networkedit():
# import objdictgen.ui.networkedit

def test_import_ui_networkeditortemplate():
import objdictgen.ui.networkeditortemplate
# def test_import_ui_networkeditortemplate():
# import objdictgen.ui.networkeditortemplate

def test_import_ui_objdictedit():
import objdictgen.ui.objdictedit
# def test_import_ui_objdictedit():
# import objdictgen.ui.objdictedit

def test_import_ui_subindextable():
import objdictgen.ui.subindextable
# def test_import_ui_subindextable():
# import objdictgen.ui.subindextable
59 changes: 0 additions & 59 deletions tests/test_objdictgen.py

This file was deleted.

0 comments on commit d2cb865

Please sign in to comment.