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
1 change: 0 additions & 1 deletion .env

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish

on:
release:
types: [published]

permissions:
contents: read

jobs:
pypi-publish:
name: Upload release to PyPi
runs-on: ubuntu-latest
environment:
name: pypi
url: https://test.pypi.org/p/objdictgen
permissions:
id-token: write
strategy:
matrix:
python-version: ["3.13"]

steps:
- name: Checkout the repository
uses: actions/checkout@v5

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}

- name: Build package
run: uv build

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1

# - name: Publish package to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
51 changes: 0 additions & 51 deletions .github/workflows/python-package.yml

This file was deleted.

50 changes: 0 additions & 50 deletions .github/workflows/python-publish.yml

This file was deleted.

78 changes: 78 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Validate

on:
push:
branches:
- '**'
pull_request:
types: [opened, synchronize, reopened]

jobs:

pytest:
name: Unit testing
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.13"]
steps:
- name: Checkout the repository
uses: actions/checkout@v5
with:
fetch-depth: 0 # To ensure non-shallow git clones for sonar

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]

- name: Run pytest
run: |
pytest --cov=objdictgen --cov-report=xml --cov-branch -p no:logging --tb=no

- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@v6.0.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}


mypy:
name: Static type analysis
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v5

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]

- name: Run mypy
run: |
mypy src/objdictgen
continue-on-error: true


ruff:
name: Code linting
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v5

- name: Run ruff check
uses: astral-sh/ruff-action@v3
with:
args: check --exit-zero
src: "."
18 changes: 10 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/venv*/
venv*/
.venv*/
*.code-workspace
.vscode/
*.egg-info/
Expand All @@ -10,6 +11,11 @@ tmp*/
dist/
.nox
coverage.xml
.ruff_cache/
.mypy_cache/
uv.lock
bug_report*.txt
bin/

*.pyc
*.bak
Expand All @@ -19,10 +25,6 @@ __*
_tmp*

tests/od/extra-compare*
/*.od
/*.json
/*.jsonc

objdictgen.*
fw-can-shared
bug_report*.txt
*.od
*.json
*.jsonc
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,27 @@ and `.eds` files. It can generate c code for use with the canfestival library.

## 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):
To use this package Python3 must be installed. Use the package manager of
choice to install the package in a virtual manager. We recommend
the [uv package manager](https://docs.astral.sh/uv/).

Using uv (one of many methods)

$ uv venv
$ uv pip install objdictgen[ui] # [ui] will install GUI tools
$ uv run odg

Using pip (for Windows)

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

After this `venv/Scripts/odg.exe` (on Windows) or `venv\bin\odg` executable
exists and can be called directly to run the command.

After this `venv/Scripts/odg.exe` (on Windows) will exist and can be called
from anywhere to run it.
The `objdictgen[ui]` suffix will install the wx dependency needed for the UI
`odg edit`. If no UI is needed, this suffix can be omitted.

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

Expand Down Expand Up @@ -133,4 +142,4 @@ original work from CanFestival is:

The Python 3 port and tool improvements have been implemented under

Copyright (C) 2022-2024 Svein Seldal, Laerdal Medical AS
Copyright (C) 2022-2025 Svein Seldal, Laerdal Medical AS
8 changes: 0 additions & 8 deletions noxfile.py

This file was deleted.

28 changes: 19 additions & 9 deletions packaging/filereplacer.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@

import importlib.metadata
import os
import re
import warnings
import objdictgen
from setuptools import SetuptoolsDeprecationWarning
from setuptools.config import read_configuration
from pprint import pprint
from typing import Any

warnings.filterwarnings("ignore", category=SetuptoolsDeprecationWarning)
import objdictgen


def convert(infile, outfile):
''' Tool to replace @@{VAR_NAME} in files.'''

pat = re.compile(r'^(.*?)@@{(.[^}]+)}(.*)$', re.S)

config = read_configuration('setup.cfg')["metadata"]
config: dict[str, Any] = dict(importlib.metadata.metadata("objdictgen"))

# Generate a 4-tuple version number
version = objdictgen.__version__
version_tuple = tuple(int(x) for x in version.split('.') if x.isdigit())
version_tuple = version_tuple + (0,) * (4 - len(version_tuple))

# Some hacks
config['version_tuple'] = objdictgen.__version_tuple__
config['copyright'] = objdictgen.__copyright__
config['_version_tuple'] = version_tuple
config['_copyright'] = objdictgen.__copyright__

# Shorten description for file description field and print it
pr_config = config.copy()
pr_config["Description"] = pr_config["Description"][0:60] + "..."
pprint(pr_config)

with open(infile, "r", encoding="utf-8") as fin:
out = ''
Expand All @@ -45,6 +53,8 @@ def convert(infile, outfile):
with open(outfile, 'w', encoding="utf-8") as fout:
fout.write(out)

print(f"Converted {infile} -> {outfile}\n{out}")


if __name__ == '__main__':
import argparse
Expand Down
12 changes: 6 additions & 6 deletions packaging/objdictedit.ver.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0.
filevers=@@{version_tuple},
prodvers=@@{version_tuple},
filevers=@@{_version_tuple},
prodvers=@@{_version_tuple},
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f,
# Contains a bitmask that specifies the Boolean attributes of the file.
Expand All @@ -30,13 +30,13 @@ StringFileInfo(
StringTable(
u'040904B0',
[StringStruct(u'CompanyName', u'Object Dictionary Editor'),
StringStruct(u'FileDescription', u'@@{description}'),
StringStruct(u'FileVersion', u'@@{version}'),
StringStruct(u'FileDescription', u'@@{Summary}'),
StringStruct(u'FileVersion', u'@@{Version}'),
StringStruct(u'InternalName', u'objdictedit'),
StringStruct(u'LegalCopyright', u'@@{copyright}'),
StringStruct(u'LegalCopyright', u'@@{_copyright}'),
StringStruct(u'OriginalFilename', u'objdictedit.exe'),
StringStruct(u'ProductName', u'objdictedit'),
StringStruct(u'ProductVersion', u'@@{version}')])
StringStruct(u'ProductVersion', u'@@{Version}')])
]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
]
Expand Down
Loading
Loading