Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash on loading DICOM specs 2022b #16

Merged
merged 2 commits into from
Jul 7, 2022
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
11 changes: 4 additions & 7 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
exclude:
- os: macOS-latest
python-version: 3.6
python-version: [3.7, 3.8, 3.9, "3.10"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand All @@ -29,14 +26,14 @@ jobs:
pip install -r requirements-dev.txt
- name: Run tests with coverage
run: |
if [[ '${{ matrix.os }}' == 'ubuntu-latest' && '${{ matrix.python-version }}' == '3.7' ]]
if [[ '${{ matrix.os }}' == 'ubuntu-latest' && '${{ matrix.python-version }}' == '3.9' ]]
then
python -m pytest --cov=dicom_validator --cov-config=.coveragerc dicom_validator
else
python -m pytest dicom_validator
fi
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
if: ${{ success() && matrix.python-version == 3.7 && matrix.os == 'ubuntu-latest' }}
if: ${{ success() && matrix.python-version == 3.9 && matrix.os == 'ubuntu-latest' }}
with:
name: codecov-dicom-validator
7 changes: 6 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ The released versions correspond to PyPi releases.
### Fixes
* condition parser: multiple or expressions handled correctly
* Condition parser: handle a few more complicated conditions
* Condition parser: handle conditions without values,
see [#15](../.. /issues/15)

### Changes
* Removed support for Python 3.6

## [Version 0.3.4](https://pypi.python.org/pypi/dicom-validator/0.3.3) (2021-11-22)
Fixes a regression introduced with the last release.

### Fixes
- fixed regression that broke the validator command line tool
- fixed regression that broke the validator command line tool,
see [#9](../../issues/9))

## [Version 0.3.3](https://pypi.python.org/pypi/dicom-validator/0.3.3) (2021-11-20)
Expand Down
14 changes: 10 additions & 4 deletions dicom_validator/spec_reader/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,30 @@ def to_string(self, dict_info: Dict) -> str:
result = self.tag
if self.index:
result += '[{}]'.format(self.index)
if self.operator is None:
return result
if self.operator == '+':
result += ' exists'
elif self.operator == '++':
result += ' exists and has a value'
elif self.operator == '-':
result += ' is not present'
elif self.operator == '=>':
tag_value = int(self.values[0])
result += ' points to ' + tag_name_from_id(tag_value, dict_info)
elif self.operator == '-':
result += ' is not present'
elif not self.values:
# if no values are found here, we have some unhandled condition
# and ignore it for the time being
return result
elif self.operator == '=':
result += ' is equal to '
values = ['"' + value + '"' for value in self.values]
result += ' is equal to '
if len(values) > 1:
result += ', '.join(values[:-1]) + ' or '
result += values[-1]
elif self.operator == '!=':
result += ' is not equal to '
values = ['"' + value + '"' for value in self.values]
result += ' is not equal to '
if len(values) > 1:
result += ', '.join(values[:-1]) + ' and '
result += values[-1]
Expand Down
6 changes: 4 additions & 2 deletions dicom_validator/spec_reader/condition_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ def parse(self, condition_str: str) -> Condition:
"""Parse the given condition string and return a Condition object
with the required attributes.
"""
condition_prefixes = ('required if ', 'shall be present if ',
'required for images where ')
condition_prefixes = (
'required if ', 'shall be present if ',
'required for images where ', 'required only if'
)
for prefix in condition_prefixes:
index = condition_str.lower().find(prefix)
if index >= 0:
Expand Down
Loading