pyprocessors-nameparser 0.6.23__tar.gz → 0.7.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {pyprocessors_nameparser-0.6.23 → pyprocessors_nameparser-0.7.2}/.gitignore +0 -16
  2. {pyprocessors_nameparser-0.6.23 → pyprocessors_nameparser-0.7.2}/Dockerfile +4 -4
  3. {pyprocessors_nameparser-0.6.23 → pyprocessors_nameparser-0.7.2}/Jenkinsfile +31 -89
  4. pyprocessors_nameparser-0.7.2/PKG-INFO +66 -0
  5. pyprocessors_nameparser-0.7.2/README.md +23 -0
  6. {pyprocessors_nameparser-0.6.23 → pyprocessors_nameparser-0.7.2}/pyprocessors_nameparser/__init__.py +1 -2
  7. {pyprocessors_nameparser-0.6.23 → pyprocessors_nameparser-0.7.2}/pyprocessors_nameparser/name_parser.py +10 -18
  8. pyprocessors_nameparser-0.7.2/pyproject.toml +83 -0
  9. pyprocessors_nameparser-0.7.2/setup.py +46 -0
  10. pyprocessors_nameparser-0.7.2/tests/test_nameparser.py +23 -0
  11. pyprocessors_nameparser-0.7.2/tox.ini +51 -0
  12. pyprocessors_nameparser-0.6.23/.pre-commit-config.yaml +0 -14
  13. pyprocessors_nameparser-0.6.23/MIGRATION.md +0 -170
  14. pyprocessors_nameparser-0.6.23/PKG-INFO +0 -89
  15. pyprocessors_nameparser-0.6.23/README.md +0 -49
  16. pyprocessors_nameparser-0.6.23/pyproject.toml +0 -77
  17. pyprocessors_nameparser-0.6.23/tests/test_nameparser.py +0 -73
  18. pyprocessors_nameparser-0.6.23/trivy-html-template.tpl +0 -148
  19. {pyprocessors_nameparser-0.6.23 → pyprocessors_nameparser-0.7.2}/.dockerignore +0 -0
  20. {pyprocessors_nameparser-0.6.23 → pyprocessors_nameparser-0.7.2}/bumpversion.py +0 -0
  21. {pyprocessors_nameparser-0.6.23 → pyprocessors_nameparser-0.7.2}/tests/__init__.py +0 -0
  22. {pyprocessors_nameparser-0.6.23 → pyprocessors_nameparser-0.7.2}/tests/data/afp_ner_fr-document-test-anon.json +0 -0
  23. {pyprocessors_nameparser-0.6.23 → pyprocessors_nameparser-0.7.2}/tests/data/afp_ner_fr-document-test.json +0 -0
  24. {pyprocessors_nameparser-0.6.23 → pyprocessors_nameparser-0.7.2}/tests/data/mindspeak_demo-document-test-anon.json +0 -0
  25. {pyprocessors_nameparser-0.6.23 → pyprocessors_nameparser-0.7.2}/tests/data/mindspeak_demo-document-test.json +0 -0
  26. {pyprocessors_nameparser-0.6.23 → pyprocessors_nameparser-0.7.2}/tests/data/terrorisme_ner_v2-document-test-anon.json +0 -0
  27. {pyprocessors_nameparser-0.6.23 → pyprocessors_nameparser-0.7.2}/tests/data/terrorisme_ner_v2-document-test.json +0 -0
@@ -18,19 +18,3 @@ log
18
18
 
19
19
  # Unit test / coverage reports
20
20
  .tox/
21
-
22
- # Sphinx docs
23
- docs/_build/
24
- audit-report.json
25
-
26
- # Specific
27
- .idea/
28
- .groovylintrc.json
29
- .emailNotif
30
- uv.lock
31
-
32
- # SBOMs
33
- **/sbom*.json
34
- **/trivy*.html
35
- **/audit*.json
36
-
@@ -1,4 +1,4 @@
1
- FROM python:3.12-slim-bookworm
1
+ FROM python:3.8-slim-bookworm
2
2
  # Install prerequisites
3
3
  RUN apt-get update -y && \
4
4
  apt-get install -y \
@@ -11,9 +11,9 @@ RUN apt-get update -y && \
11
11
  apt-get update -y && \
12
12
  apt-get clean all -y
13
13
 
14
- # Install uv
15
- RUN pip install uv
14
+ # Enable Installing packages as root
15
+ ENV FLIT_ROOT_INSTALL=1
16
16
 
17
- # Add pyproject.toml + README.md for uv install
17
+ # Add pyproject.toml + README.md for flit install
18
18
  ADD pyproject.toml pyproject.toml
19
19
  ADD README.md README.md
@@ -6,6 +6,14 @@ pipeline {
6
6
 
7
7
  agent none
8
8
 
9
+ options {
10
+ throttleJobProperty(
11
+ categories: ['pyprocessors'],
12
+ throttleEnabled: true,
13
+ throttleOption: 'category'
14
+ )
15
+ }
16
+
9
17
  triggers {
10
18
  upstream(upstreamProjects: 'pymultirole_plugins/' + BRANCH_NAME.replaceAll('/', '%2F'),\
11
19
  threshold: hudson.model.Result.SUCCESS)
@@ -19,15 +27,15 @@ pipeline {
19
27
  PYTHONDONTWRITEBYTECODE = '1'
20
28
  JENKINS_UIDGID = '1004:1004'
21
29
 
22
- MAJOR_VERSION = '0'
23
- MINOR_VERSION = '6'
30
+ MAJOR_VERSION = "${MAJOR_VERSION_PY38}"
31
+ MINOR_VERSION = "${MINOR_VERSION_PY38_HOTFIX}"
24
32
  }
25
33
 
26
34
  stages {
27
35
  stage('Catch build termination') {
28
36
  agent {
29
37
  node {
30
- label 'built-in'
38
+ label 'pre-build'
31
39
  customWorkspace "${PATH_HOME}/${JOB_NAME}"
32
40
  }
33
41
  }
@@ -58,7 +66,7 @@ pipeline {
58
66
  stage('Add credentials') {
59
67
  steps {
60
68
  script {
61
- // Add password file for uv publishing
69
+ // Add password file for flit publishing
62
70
  sh "cp ${PATH_HOME}/.passwd-pypi .env"
63
71
  }
64
72
  }
@@ -73,7 +81,6 @@ pipeline {
73
81
  withCredentials([gitUsernamePassword(credentialsId: 'bitbucket-user', gitToolName: 'git-tool')]) {
74
82
  sh 'git pull'
75
83
  sh "echo '\"\"\"Processor based on Nameparser\"\"\"' > pyprocessors_nameparser/__init__.py"
76
- sh "echo '' >> pyprocessors_nameparser/__init__.py"
77
84
  sh "echo '__version__ = \"${MAJOR_VERSION}.${MINOR_VERSION}.${BUILD_ID}\"' >> pyprocessors_nameparser/__init__.py"
78
85
  sh 'git commit pyprocessors_nameparser/__init__.py -m "[Jenkins CI] Commit on version files" || echo "No changes to commit"'
79
86
  sh 'git push'
@@ -96,7 +103,7 @@ pipeline {
96
103
  // - docker: /root/test-reports
97
104
  // - host : /tmp/_${JOB_NAME}/test-reports
98
105
  dockerfile {
99
- label 'built-in'
106
+ label 'docker-build'
100
107
  customWorkspace "${PATH_HOME}/${JOB_NAME}"
101
108
  filename 'Dockerfile'
102
109
  args "-u root --privileged -v /tmp/_${JOB_NAME}/test-reports:${TEST_REPORT_DIR}"
@@ -104,11 +111,13 @@ pipeline {
104
111
  }
105
112
 
106
113
  stages {
107
- stage('Install dependencies') {
114
+ stage('Install flit & flake8') {
108
115
  steps {
109
- sh 'rm -f uv.lock'
110
- sh 'pip install uv'
111
- sh 'uv sync --no-cache --extra test'
116
+ // remove any previous tox env
117
+ sh 'rm -rf .tox'
118
+ sh 'python -m pip install pip==22.0.3'
119
+ sh 'pip install --no-cache-dir flit==3.2.0 flake8==3.9.2 flakehell tox'
120
+ sh 'flit install'
112
121
  }
113
122
  }
114
123
 
@@ -116,20 +125,20 @@ pipeline {
116
125
  steps {
117
126
  // remove any previous results.xml file
118
127
  sh "rm -f ${TEST_REPORT_DIR}/results.xml"
119
- sh 'uv run ruff check .'
120
- sh 'uv run ruff format --check .'
121
- sh "uv run pytest --junit-xml=${TEST_REPORT_DIR}/results.xml"
128
+ sh 'tox'
122
129
  }
123
130
  }
124
131
 
125
132
  stage('Publish on PyPI') {
126
133
  environment {
127
- UV_PUBLISH_USERNAME = getUserName '.env'
128
- UV_PUBLISH_PASSWORD = getUserPass '.env'
134
+ FLIT_USERNAME = getUserName '.env'
135
+ FLIT_PASSWORD = getUserPass '.env'
129
136
  }
130
137
  steps {
131
138
  // remove any previous folder dist
132
139
  sh 'rm -rf dist'
140
+ // create (as root) folder dist
141
+ sh 'mkdir dist'
133
142
  // pull recent updates of file __init__.py
134
143
  withCredentials([gitUsernamePassword(credentialsId: 'bitbucket-user', gitToolName: 'git-tool')]) {
135
144
  sh 'git config --global pull.rebase false'
@@ -142,85 +151,18 @@ pipeline {
142
151
  sh "chown ${JENKINS_UIDGID} pyprocessors_nameparser/__init__.py"
143
152
  // get git status
144
153
  sh 'git status'
145
- // build and publish on PyPI
154
+ // publish on PyPI
146
155
  sh '''
147
156
  export COMMIT_VERSION=$( cat pyprocessors_nameparser/__init__.py|grep version|cut -d '"' -f2|tr -s '[:blank:]' )
148
157
  export BUILD_VERSION="${MAJOR_VERSION}"."${MINOR_VERSION}"."${BUILD_ID}"
149
- if [ "${COMMIT_VERSION}" = "${BUILD_VERSION}" ] ; then uv build && uv publish ; fi
158
+ if [ "${COMMIT_VERSION}" = "${BUILD_VERSION}" ] ; then flit publish ; fi
150
159
  '''
151
160
  // remove current folder dist
152
161
  sh 'rm -rf dist'
153
162
  // remove current folder .hypothesis
154
163
  sh 'rm -rf .hypothesis'
155
- }
156
- }
157
- }
158
- }
159
-
160
- stage('Prepare SBOM') {
161
- when {
162
- beforeAgent true
163
- environment name: 'SKIP_JOB', value: '0'
164
- }
165
- options {
166
- timeout(time: 120, unit: 'SECONDS')
167
- }
168
-
169
- agent {
170
- docker {
171
- image 'alpine:3.19'
172
- label 'built-in'
173
- customWorkspace "${PATH_HOME}/${JOB_NAME}"
174
- args "-u 0"
175
- }
176
- }
177
-
178
- stages {
179
- stage('Generate SBOM') {
180
- steps {
181
- sh '''
182
- apk add --no-cache curl
183
-
184
- curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b . v${SYFT_VERSION}
185
-
186
- ./syft . \
187
- --exclude '**/syft' \
188
- --exclude '**/.pytest_cache' \
189
- --exclude '**/.ruff_cache' \
190
- --exclude '**/sbom.cdx.json' \
191
- --exclude '**/sbom.spdx.json' \
192
- --source-name "${JOB_NAME}" \
193
- --source-version "${BUILD_NUMBER}" \
194
- -o cyclonedx-json=sbom.cdx.json \
195
- -o spdx-json=sbom.spdx.json
196
-
197
- rm -f ./syft
198
- '''
199
- }
200
- }
201
-
202
- stage('Analyse SBOM') {
203
- steps {
204
- sh '''
205
- curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b . v${TRIVY_VERSION}
206
- curl -L https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/html.tpl -o trivy-html-template.tpl
207
-
208
- ./trivy sbom --download-db-only
209
-
210
- ./trivy sbom sbom.cdx.json \
211
- --skip-db-update \
212
- --format template \
213
- --template "@trivy-html-template.tpl" \
214
- -o trivy-report.html
215
-
216
- rm -f ./trivy
217
- '''
218
- }
219
- }
220
-
221
- stage('Archive SBOM & analysis') {
222
- steps {
223
- archiveArtifacts artifacts: 'sbom*.json, trivy*.html', fingerprint: true
164
+ // remove current folder .tox
165
+ sh 'rm -rf .tox'
224
166
  }
225
167
  }
226
168
  }
@@ -305,7 +247,7 @@ pipeline {
305
247
  }
306
248
  }
307
249
 
308
- // return UV_PUBLISH_USERNAME from given file (reads FLIT_USERNAME key)
250
+ // return FLIT_USERNAME from given file
309
251
  def getUserName(path) {
310
252
  def USERNAME = sh(
311
253
  script: "grep FLIT_USERNAME ${path}|cut -d '=' -f2",
@@ -314,7 +256,7 @@ def getUserName(path) {
314
256
  return USERNAME
315
257
  }
316
258
 
317
- // return UV_PUBLISH_PASSWORD from given file (reads FLIT_PASSWORD key)
259
+ // return FLIT_PASSWORD from given file
318
260
  def getUserPass(path) {
319
261
  def USERPASS = sh(
320
262
  script: "grep FLIT_PASSWORD ${path}|cut -d '=' -f2",
@@ -475,6 +417,6 @@ def analyseBuildCause() {
475
417
  println 'Skipping build because last commit has been done by CI'
476
418
  env.SKIP_JOB = '1'
477
419
  switchEmailNotif(false, 0)
478
- currentBuild.result = 'NOT_BUILT'
420
+ //currentBuild.result = 'NOT_BUILT'
479
421
  }
480
422
  }
@@ -0,0 +1,66 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyprocessors-nameparser
3
+ Version: 0.7.2
4
+ Summary: Processor based on Nameparser
5
+ Home-page: https://kairntech.com/
6
+ Author: Olivier Terrier
7
+ Author-email: olivier.terrier@kairntech.com
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ Classifier: Intended Audience :: Information Technology
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: System Administrators
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Software Development :: Libraries
17
+ Classifier: Topic :: Software Development
18
+ Classifier: License :: OSI Approved :: MIT License
19
+ Classifier: Development Status :: 4 - Beta
20
+ Classifier: Programming Language :: Python :: 3.8
21
+ Requires-Dist: pymultirole-plugins>=0.7.0,<0.8.0
22
+ Requires-Dist: log-with-context
23
+ Requires-Dist: nameparser
24
+ Requires-Dist: flit ; extra == "dev"
25
+ Requires-Dist: pre-commit ; extra == "dev"
26
+ Requires-Dist: bump2version ; extra == "dev"
27
+ Requires-Dist: sphinx ; extra == "docs"
28
+ Requires-Dist: sphinx-rtd-theme ; extra == "docs"
29
+ Requires-Dist: m2r2 ; extra == "docs"
30
+ Requires-Dist: sphinxcontrib.apidoc ; extra == "docs"
31
+ Requires-Dist: jupyter_sphinx ; extra == "docs"
32
+ Requires-Dist: pytest ; extra == "test"
33
+ Requires-Dist: pytest-cov ; extra == "test"
34
+ Requires-Dist: pytest-flake8 ; extra == "test"
35
+ Requires-Dist: pytest-black ; extra == "test"
36
+ Requires-Dist: flake8==3.9.2 ; extra == "test"
37
+ Requires-Dist: tox ; extra == "test"
38
+ Requires-Dist: dirty-equals ; extra == "test"
39
+ Provides-Extra: dev
40
+ Provides-Extra: docs
41
+ Provides-Extra: test
42
+
43
+ ## Requirements
44
+
45
+ - Python 3.8+
46
+ - Flit to put Python packages and modules on PyPI
47
+ - Pydantic for the data parts.
48
+
49
+ ## Installation
50
+ ```
51
+ pip install flit
52
+ pip install pymultirole-plugins
53
+ ```
54
+
55
+ ## Publish the Python Package to PyPI
56
+ - Increment the version of your package in the `__init__.py` file:
57
+ ```
58
+ """An amazing package!"""
59
+
60
+ __version__ = 'x.y.z'
61
+ ```
62
+ - Publish
63
+ ```
64
+ flit publish
65
+ ```
66
+
@@ -0,0 +1,23 @@
1
+ ## Requirements
2
+
3
+ - Python 3.8+
4
+ - Flit to put Python packages and modules on PyPI
5
+ - Pydantic for the data parts.
6
+
7
+ ## Installation
8
+ ```
9
+ pip install flit
10
+ pip install pymultirole-plugins
11
+ ```
12
+
13
+ ## Publish the Python Package to PyPI
14
+ - Increment the version of your package in the `__init__.py` file:
15
+ ```
16
+ """An amazing package!"""
17
+
18
+ __version__ = 'x.y.z'
19
+ ```
20
+ - Publish
21
+ ```
22
+ flit publish
23
+ ```
@@ -1,3 +1,2 @@
1
1
  """Processor based on Nameparser"""
2
-
3
- __version__ = "0.6.23"
2
+ __version__ = "0.7.2"
@@ -1,32 +1,24 @@
1
1
  from logging import Logger
2
- from typing import cast
3
-
2
+ from typing import List, Type, cast
4
3
  from log_with_context import add_logging_context
5
4
  from nameparser import HumanName
6
- from pydantic import BaseModel, Field
7
- from pymultirole_plugins.v1.processor import ProcessorBase, ProcessorParameters
5
+ from pydantic import Field, BaseModel
6
+ from pymultirole_plugins.v1.processor import ProcessorParameters, ProcessorBase
8
7
  from pymultirole_plugins.v1.schema import Document
9
8
 
10
9
  logger = Logger("pymultirole")
11
10
 
12
11
 
13
12
  class NameParserParameters(ProcessorParameters):
14
- name_labels: list[str] = Field(
15
- None,
16
- description="Annotation labels whose text should be parsed as human names. "
17
- "Only annotations matching one of these labels will be processed.",
18
- json_schema_extra={"extra": "label"},
19
- )
13
+ name_labels: List[str] = Field(None, description="List of labels to analyze", extra="label")
20
14
 
21
15
 
22
16
  class NameParserProcessor(ProcessorBase):
23
- __doc__ = (
24
- """Human name parser that extracts structured name components (title, first, middle, last, suffix, nickname) """
25
- """from annotated text spans using [Nameparser](https://github.com/derek73/python-nameparser).<br/>"""
26
- """The parsed components are added as properties to each matching annotation."""
27
- )
17
+ __doc__ = """NameParser based on [Nameparser](https://github.com/derek73/python-nameparser)."""
28
18
 
29
- def process(self, documents: list[Document], parameters: ProcessorParameters) -> list[Document]:
19
+ def process(
20
+ self, documents: List[Document], parameters: ProcessorParameters
21
+ ) -> List[Document]:
30
22
  params: NameParserParameters = cast(NameParserParameters, parameters)
31
23
  try:
32
24
  for document in documents:
@@ -34,7 +26,7 @@ class NameParserProcessor(ProcessorBase):
34
26
  if document.annotations:
35
27
  for a in document.annotations:
36
28
  if a.labelName in params.name_labels:
37
- atext = a.text or document.text[a.start : a.end]
29
+ atext = a.text or document.text[a.start:a.end]
38
30
  name = HumanName(atext)
39
31
  props = a.properties or {}
40
32
  props.update(name.as_dict())
@@ -44,5 +36,5 @@ class NameParserProcessor(ProcessorBase):
44
36
  return documents
45
37
 
46
38
  @classmethod
47
- def get_model(cls) -> type[BaseModel]:
39
+ def get_model(cls) -> Type[BaseModel]:
48
40
  return NameParserParameters
@@ -0,0 +1,83 @@
1
+ [build-system]
2
+ requires = ["flit_core >=3.2,<4"]
3
+ #requires = ["flit_core >=2,<3"]
4
+ build-backend = "flit_core.buildapi"
5
+
6
+ [tool.flit.metadata]
7
+ module = "pyprocessors_nameparser"
8
+ author = "Olivier Terrier"
9
+ author-email = "olivier.terrier@kairntech.com"
10
+ home-page = "https://kairntech.com/"
11
+ classifiers = [
12
+ "Intended Audience :: Information Technology",
13
+ "Intended Audience :: Developers",
14
+ "Intended Audience :: System Administrators",
15
+ "Operating System :: OS Independent",
16
+ "Topic :: Software Development :: Libraries :: Application Frameworks",
17
+ "Topic :: Software Development :: Libraries :: Python Modules",
18
+ "Topic :: Software Development :: Libraries",
19
+ "Topic :: Software Development",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Development Status :: 4 - Beta",
22
+ "Programming Language :: Python :: 3.8",
23
+ ]
24
+ requires = [
25
+ "pymultirole-plugins>=0.7.0,<0.8.0",
26
+ "log-with-context",
27
+ "nameparser"
28
+ ]
29
+ dist-name = "pyprocessors-nameparser"
30
+ description-file = "README.md"
31
+ requires-python = ">=3.8"
32
+
33
+ [tool.flit.entrypoints."pyprocessors.plugins"]
34
+ nameparser = "pyprocessors_nameparser.name_parser:NameParserProcessor"
35
+ [tool.flit.metadata.requires-extra]
36
+ test = [
37
+ "pytest",
38
+ "pytest-cov",
39
+ "pytest-flake8",
40
+ "pytest-black",
41
+ # "hypothesis",
42
+ "flake8==3.9.2",
43
+ "tox",
44
+ "dirty-equals"
45
+ ]
46
+ docs = [
47
+ "sphinx",
48
+ "sphinx-rtd-theme",
49
+ "m2r2", # markdown support
50
+ "sphinxcontrib.apidoc", # run sphinx-apidoc when building docs
51
+ "jupyter_sphinx", # for execution of code snippets in the documentation
52
+ ]
53
+ dev = [
54
+ "flit",
55
+ "pre-commit",
56
+ "bump2version",
57
+ ]
58
+
59
+ [tool.flakehell]
60
+ exclude = ["README.md"]
61
+ format = "colored"
62
+ #format = "junit-xml"
63
+ max_line_length = 120
64
+ show_source = true
65
+ #whitelist = "../../allowlist.txt"
66
+
67
+ [tool.flakehell.plugins]
68
+ flake8-bandit = ["+*", "-S322"]
69
+ flake8-bugbear = ["+*"]
70
+ flake8-builtins = ["+*"]
71
+ flake8-comprehensions = ["+*"]
72
+ #flake8-darglint = ["+*"]
73
+ flake8-docstrings = ["+*"]
74
+ flake8-eradicate = ["+*"]
75
+ flake8-isort = ["+*"]
76
+ flake8-mutable = ["+*"]
77
+ flake8-pytest-style = ["+*"]
78
+ flake8-spellcheck = ["+*"]
79
+ mccabe = ["+*"]
80
+ pep8-naming = ["+*"]
81
+ pycodestyle = ["+*"]
82
+ pyflakes = ["+*"]
83
+ pylint = ["+*"]
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env python
2
+ # setup.py generated by flit for tools that don't yet use PEP 517
3
+
4
+ from distutils.core import setup
5
+
6
+ packages = \
7
+ ['pyprocessors_nameparser']
8
+
9
+ package_data = \
10
+ {'': ['*']}
11
+
12
+ install_requires = \
13
+ ['pymultirole-plugins>=0.7.0,<0.8.0', 'log-with-context', 'nameparser']
14
+
15
+ extras_require = \
16
+ {'dev': ['flit', 'pre-commit', 'bump2version'],
17
+ 'docs': ['sphinx',
18
+ 'sphinx-rtd-theme',
19
+ 'm2r2',
20
+ 'sphinxcontrib.apidoc',
21
+ 'jupyter_sphinx'],
22
+ 'test': ['pytest',
23
+ 'pytest-cov',
24
+ 'pytest-flake8',
25
+ 'pytest-black',
26
+ 'flake8==3.9.2',
27
+ 'tox',
28
+ 'dirty-equals']}
29
+
30
+ entry_points = \
31
+ {'pyprocessors.plugins': ['nameparser = '
32
+ 'pyprocessors_nameparser.name_parser:NameParserProcessor']}
33
+
34
+ setup(name='pyprocessors-nameparser',
35
+ version='0.7.2',
36
+ description='Processor based on Nameparser',
37
+ author='Olivier Terrier',
38
+ author_email='olivier.terrier@kairntech.com',
39
+ url='https://kairntech.com/',
40
+ packages=packages,
41
+ package_data=package_data,
42
+ install_requires=install_requires,
43
+ extras_require=extras_require,
44
+ entry_points=entry_points,
45
+ python_requires='>=3.8',
46
+ )
@@ -0,0 +1,23 @@
1
+ from pymultirole_plugins.v1.schema import Document, Annotation
2
+
3
+ from pyprocessors_nameparser.name_parser import (
4
+ NameParserProcessor,
5
+ NameParserParameters
6
+ )
7
+
8
+
9
+ def test_model():
10
+ model = NameParserProcessor.get_model()
11
+ model_class = model.construct().__class__
12
+ assert model_class == NameParserParameters
13
+
14
+
15
+ def test_nameparser():
16
+ processor = NameParserProcessor()
17
+ parameters = NameParserParameters(name_labels=['auteur'])
18
+ doc = Document(text="Olivier Terrier",
19
+ annotations=[Annotation(label='Auteur', labelName='auteur', start=0, end=15)])
20
+ docs = processor.process([doc], parameters)
21
+ doc0 = docs[0]
22
+ ot = doc0.annotations[0]
23
+ assert len(ot.properties) > 0
@@ -0,0 +1,51 @@
1
+ [tox]
2
+ isolated_build = True
3
+ envlist = clean,py38,report
4
+
5
+ [gh-actions]
6
+ python =
7
+ 3.8: clean,py38,report
8
+
9
+ [pytest]
10
+ addopts =
11
+ --durations=5
12
+ --flake8
13
+ norecursedirs =
14
+ docs
15
+
16
+ filterwarnings =
17
+ ignore:<class '.*'> is not using a cooperative constructor:pytest.PytestDeprecationWarning
18
+ ignore:The \(fspath. py.path.local\) argument to .* is deprecated.:pytest.PytestDeprecationWarning
19
+ ignore:.* is an Item subclass and should not be a collector.*:pytest.PytestWarning
20
+
21
+ [testenv]
22
+ deps = .[test]
23
+ commands = pytest --junit-xml={env:TEST_REPORT_DIR:.}/{env:TEST_REPORT_FILE:results.xml}
24
+ passenv = *
25
+ depends =
26
+ report: py38
27
+
28
+ [testenv:docs]
29
+ changedir=docs
30
+ deps = .[docs]
31
+ commands = sphinx-build . _build
32
+
33
+ [flake8]
34
+ max-line-length = 100
35
+ ignore =
36
+ E131,
37
+ E203,
38
+ E266,
39
+ E501,
40
+ W503,
41
+ W291,
42
+ C901
43
+ per-file-ignores =
44
+ __init__.py: F401
45
+ max-complexity = 18
46
+ select = B, C, E, F, W, T4, B9
47
+ exclude =
48
+ .git,
49
+ .tox,
50
+ __pycache__,
51
+ dist,
@@ -1,14 +0,0 @@
1
- repos:
2
- - repo: https://github.com/astral-sh/ruff-pre-commit
3
- rev: v0.3.0
4
- hooks:
5
- - id: ruff
6
- args: [--fix]
7
- - id: ruff-format
8
- - repo: https://github.com/pre-commit/pre-commit-hooks
9
- rev: v4.5.0
10
- hooks:
11
- - id: end-of-file-fixer
12
- exclude: '.bumpversion.cfg'
13
- - id: trailing-whitespace
14
- exclude: '.bumpversion.cfg'
@@ -1,170 +0,0 @@
1
- # Migration to Python 3.12, Pydantic v2, and uv tooling
2
-
3
- This document describes the migration steps to perform on this project according to past experience. Please apply all these changes if they make sense.
4
-
5
- ## 0. Initial setup
6
- - git pull the current master branch
7
- - create a py312 git branch and switch to it
8
- - change pyenv local to pymultirole312
9
- - reset version in __init__.py to 0.6.0
10
-
11
- ## 1. Build system: flit → hatchling/uv
12
-
13
- The build system was migrated from **flit** to **hatchling** with **uv** as the package manager.
14
-
15
- - `pyproject.toml`: rewritten from flit legacy format (`[tool.flit.metadata]`) to PEP 621
16
- with `hatchling` backend and `[project]` table
17
- - Version read dynamically from `src/pyconverters_pyword/__init__.py` via `[tool.hatch.version]`
18
- - Entry point `pyconverters.plugins` moved from `[tool.flit.entrypoints]` to `[project.entry-points]`
19
- - Replaced `flit` commands with `uv build` and `uv publish`
20
- - Jenkinsfile updated to use `uv sync` and `uv build`/`uv publish`
21
- - Dockerfile updated to install `uv` via `COPY --from=ghcr.io/astral-sh/uv:latest`
22
-
23
- ## 2. Python version: 3.8+ → 3.12
24
-
25
- - `requires-python` set to `>=3.12` in `pyproject.toml`
26
- - `Dockerfile` base image changed from `python:3.8-slim-bookworm` to `python:3.12-slim-bookworm`
27
- - `FLIT_ROOT_INSTALL=1` env var removed from Dockerfile (no longer needed)
28
- - Classifiers updated from `Python :: 3.8` to `Python :: 3.12`
29
-
30
- ## 3. Pydantic v1 → v2
31
-
32
- Replaced deprecated Pydantic v1 APIs in `pyword.py` and `tests/test_pyword.py`:
33
-
34
- - `.json(exclude_none=True, exclude_unset=True, indent=2)` → `.model_dump_json(...)` in tests
35
- - `DocumentList(__root__=docs)` → `DocumentList(root=docs)` (Pydantic v2 `RootModel` API)
36
- - `Field(extra="internal"/"advanced")` → `Field(json_schema_extra={"extra": "..."})` in `pyword.py`
37
- - `params.dict()` → `params.model_dump()` in `pyword.py`
38
-
39
- ## 3bis. Spacy
40
- For everything related to spacy look at what has been done in ../pysegmenters_rules_segmenter
41
-
42
- ## 4. Python 3.12 type modernization
43
-
44
- Leveraged Python 3.12 builtins and modern syntax (enforced by ruff `UP` rules):
45
-
46
- - `typing.List[Document]` → `list[Document]` (method signatures in `pyword.py` and tests)
47
- - `typing.Type[BaseModel]` → `type[BaseModel]` (`get_model` return type in `pyword.py`)
48
- - Removed unused `typing` imports: `List`, `Type`
49
-
50
- ## 5. Linter: black + flake8 → ruff
51
-
52
- - Removed `black`, `flake8`, `pytest-flake8`, `pytest-black`, `flakehell` dependencies
53
- - Added `ruff` to `[project.optional-dependencies].test`
54
- - Removed `[tool.flakehell]` configuration block from `pyproject.toml`
55
- - Configured `[tool.ruff]` in `pyproject.toml`:
56
- - `line-length = 120`
57
- - `target-version = "py312"`
58
- - Lint rules: `E`, `W`, `F`, `I`, `B`, `C4`, `UP`, `ARG`, `SIM`
59
- - Format: double quotes, space indent
60
- - Updated `.pre-commit-config.yaml`: replaced `black` and `flake8` hooks with `ruff` and `ruff-format`
61
-
62
- ### Running the linter
63
-
64
- ```
65
- uv run ruff check .
66
- uv run ruff format --check .
67
- ```
68
-
69
- To auto-fix formatting:
70
-
71
- ```
72
- uv run ruff format .
73
- ```
74
-
75
- ## 6. Test runner: tox → uv
76
-
77
- **tox** was removed entirely. The project now uses `uv run` to execute tests and linting directly.
78
-
79
- ### What changed
80
-
81
- - Deleted `tox.ini`
82
- - Removed `tox`, `flake8`, `pytest-flake8`, `pytest-black` from test dependencies
83
- - Moved pytest configuration from `tox.ini` to `pyproject.toml`:
84
-
85
- ```toml
86
- [tool.pytest.ini_options]
87
- addopts = "--durations=5"
88
- norecursedirs = ["docs"]
89
- ```
90
-
91
- ### Running tests
92
-
93
- ```
94
- uv run pytest
95
- ```
96
-
97
- ### Why tox was unnecessary
98
-
99
- - The project targets a single Python version (3.12)
100
- - `uv run` provides virtual environment isolation without the extra layer
101
-
102
- ## 7. Documentation generation
103
-
104
- Sphinx is used for documentation with the `docs` optional dependency group.
105
-
106
- ### Fix: added `lxml_html_clean` dependency
107
-
108
- The `jupyter_sphinx` extension requires `lxml_html_clean` (split from `lxml` in recent versions).
109
- This was added to `[project.optional-dependencies].docs`.
110
-
111
- ### Generating docs
112
-
113
- ```
114
- uv run --extra docs sphinx-build docs docs/_build
115
- ```
116
-
117
- ## 8. Jenkinsfile updates
118
-
119
- - `__init__.py` generation now includes a blank line between the docstring and `__version__`
120
- to comply with `ruff format`
121
- - Set `__version__ = "0.6.0"`
122
- - In Jenkinsfile, set `MINOR_VERSION = "6"`
123
- - Install step changed from `flit install` to `uv sync --extra test`
124
- - Lint step added: `uv run ruff check .` + `uv run ruff format --check .`
125
- - Test step changed from `tox` to `uv run pytest --junit-xml=...`
126
- - Build/publish pipeline uses `uv build && uv publish` instead of `flit publish`
127
- - Credentials: Jenkinsfile helper functions still read `FLIT_USERNAME` and `FLIT_PASSWORD`
128
- from `.passwd-pypi`, but expose them as `UV_PUBLISH_USERNAME` and `UV_PUBLISH_PASSWORD`
129
- for `uv publish`
130
- - Removed `.tox` cleanup steps
131
-
132
- ## 9. .gitignore updates
133
-
134
- Added the following entry:
135
- - `uv.lock` — generated lock file, not committed
136
-
137
- (`docs/_build/` was already present.)
138
-
139
- ## 10. Dependency cleanup and upgrades
140
-
141
- ### Removed unused dependencies
142
-
143
- - None
144
-
145
- ### Upgraded pinned dependencies
146
-
147
- - `pymultirole-plugins>=0.5.0,<0.6.0` → `pymultirole-plugins>=0.6.0,<0.7.0`
148
- - update dependencies to latest versions if possible
149
-
150
- ## 11. Starlette `UploadFile` API change
151
-
152
- The `UploadFile` constructor signature changed in recent Starlette versions:
153
-
154
- **Before (old API):**
155
- ```python
156
- UploadFile(filename, file, content_type) # positional args
157
- ```
158
-
159
- **After (new API):**
160
- ```python
161
- UploadFile(file=..., filename=..., headers=Headers({"content-type": "..."}))
162
- ```
163
-
164
- Updated in `tests/test_pyword.py` and added `Headers` import from `starlette.datastructures`.
165
-
166
- ## 12. Additional unit tests
167
-
168
- - Analyze src directory and extended `tests/` with tests covering previously untested behaviour
169
-
170
- ## 13. Update README.md
@@ -1,89 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pyprocessors-nameparser
3
- Version: 0.6.23
4
- Summary: Processor based on Nameparser
5
- Project-URL: Homepage, https://kairntech.com/
6
- Author-email: Olivier Terrier <olivier.terrier@kairntech.com>
7
- Classifier: Development Status :: 4 - Beta
8
- Classifier: Intended Audience :: Developers
9
- Classifier: Intended Audience :: Information Technology
10
- Classifier: Intended Audience :: System Administrators
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Operating System :: OS Independent
13
- Classifier: Programming Language :: Python :: 3.12
14
- Classifier: Topic :: Software Development
15
- Classifier: Topic :: Software Development :: Libraries
16
- Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
17
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
- Requires-Python: >=3.12
19
- Requires-Dist: log-with-context
20
- Requires-Dist: nameparser
21
- Requires-Dist: pymultirole-plugins<0.7.0,>=0.6.0
22
- Provides-Extra: dev
23
- Requires-Dist: bump2version; extra == 'dev'
24
- Requires-Dist: pre-commit; extra == 'dev'
25
- Provides-Extra: docs
26
- Requires-Dist: lxml-html-clean; extra == 'docs'
27
- Requires-Dist: m2r2; extra == 'docs'
28
- Requires-Dist: sphinx; extra == 'docs'
29
- Requires-Dist: sphinx-rtd-theme; extra == 'docs'
30
- Requires-Dist: sphinxcontrib-apidoc; extra == 'docs'
31
- Provides-Extra: sbom
32
- Requires-Dist: cyclonedx-bom; extra == 'sbom'
33
- Requires-Dist: pip-audit; extra == 'sbom'
34
- Provides-Extra: test
35
- Requires-Dist: dirty-equals; extra == 'test'
36
- Requires-Dist: pytest; extra == 'test'
37
- Requires-Dist: pytest-cov; extra == 'test'
38
- Requires-Dist: ruff; extra == 'test'
39
- Description-Content-Type: text/markdown
40
-
41
- ## Requirements
42
-
43
- - Python 3.12+
44
- - uv for package management
45
- - Pydantic for the data parts.
46
-
47
- ## Installation
48
- ```
49
- pip install uv
50
- uv sync
51
- ```
52
-
53
- ## Publish the Python Package to PyPI
54
- - Increment the version of your package in the `__init__.py` file:
55
- ```
56
- """An amazing package!"""
57
-
58
- __version__ = 'x.y.z'
59
- ```
60
- - Publish
61
- ```
62
- uv build && uv publish
63
- ```
64
-
65
- ## SBOM & vulnerability check
66
-
67
- Install the SBOM dependencies:
68
-
69
- ```
70
- uv sync --extra sbom
71
- ```
72
-
73
- Generate a CycloneDX SBOM from the current environment:
74
-
75
- ```
76
- uv run cyclonedx-py environment -o sbom.cdx.json --output-format json
77
- ```
78
-
79
- Audit dependencies for known vulnerabilities:
80
-
81
- ```
82
- uv run pip-audit --format json --output audit-report.json
83
- ```
84
-
85
- To fail on any known vulnerability (useful in CI):
86
-
87
- ```
88
- uv run pip-audit --strict
89
- ```
@@ -1,49 +0,0 @@
1
- ## Requirements
2
-
3
- - Python 3.12+
4
- - uv for package management
5
- - Pydantic for the data parts.
6
-
7
- ## Installation
8
- ```
9
- pip install uv
10
- uv sync
11
- ```
12
-
13
- ## Publish the Python Package to PyPI
14
- - Increment the version of your package in the `__init__.py` file:
15
- ```
16
- """An amazing package!"""
17
-
18
- __version__ = 'x.y.z'
19
- ```
20
- - Publish
21
- ```
22
- uv build && uv publish
23
- ```
24
-
25
- ## SBOM & vulnerability check
26
-
27
- Install the SBOM dependencies:
28
-
29
- ```
30
- uv sync --extra sbom
31
- ```
32
-
33
- Generate a CycloneDX SBOM from the current environment:
34
-
35
- ```
36
- uv run cyclonedx-py environment -o sbom.cdx.json --output-format json
37
- ```
38
-
39
- Audit dependencies for known vulnerabilities:
40
-
41
- ```
42
- uv run pip-audit --format json --output audit-report.json
43
- ```
44
-
45
- To fail on any known vulnerability (useful in CI):
46
-
47
- ```
48
- uv run pip-audit --strict
49
- ```
@@ -1,77 +0,0 @@
1
- [build-system]
2
- requires = ["hatchling"]
3
- build-backend = "hatchling.build"
4
-
5
- [project]
6
- name = "pyprocessors-nameparser"
7
- dynamic = ["version"]
8
- description = "Processor based on Nameparser"
9
- readme = "README.md"
10
- authors = [
11
- {name = "Olivier Terrier", email = "olivier.terrier@kairntech.com"},
12
- ]
13
- classifiers = [
14
- "Intended Audience :: Information Technology",
15
- "Intended Audience :: Developers",
16
- "Intended Audience :: System Administrators",
17
- "Operating System :: OS Independent",
18
- "Topic :: Software Development :: Libraries :: Application Frameworks",
19
- "Topic :: Software Development :: Libraries :: Python Modules",
20
- "Topic :: Software Development :: Libraries",
21
- "Topic :: Software Development",
22
- "License :: OSI Approved :: MIT License",
23
- "Development Status :: 4 - Beta",
24
- "Programming Language :: Python :: 3.12",
25
- ]
26
- requires-python = ">=3.12"
27
- dependencies = [
28
- "pymultirole-plugins>=0.6.0,<0.7.0",
29
- "log-with-context",
30
- "nameparser",
31
- ]
32
-
33
- [project.urls]
34
- Homepage = "https://kairntech.com/"
35
-
36
- [project.entry-points."pyprocessors.plugins"]
37
- nameparser = "pyprocessors_nameparser.name_parser:NameParserProcessor"
38
-
39
- [project.optional-dependencies]
40
- test = [
41
- "pytest",
42
- "pytest-cov",
43
- "ruff",
44
- "dirty-equals",
45
- ]
46
- docs = [
47
- "sphinx",
48
- "sphinx-rtd-theme",
49
- "m2r2",
50
- "sphinxcontrib.apidoc",
51
- "lxml_html_clean",
52
- ]
53
- dev = [
54
- "pre-commit",
55
- "bump2version",
56
- ]
57
-
58
- sbom = ["cyclonedx-bom", "pip-audit"]
59
-
60
- [tool.hatch.version]
61
- path = "pyprocessors_nameparser/__init__.py"
62
-
63
- [tool.pytest.ini_options]
64
- addopts = "--durations=5"
65
- norecursedirs = ["docs"]
66
-
67
- [tool.ruff]
68
- line-length = 120
69
- target-version = "py312"
70
-
71
- [tool.ruff.lint]
72
- select = ["E", "W", "F", "I", "B", "C4", "UP", "ARG", "SIM"]
73
- ignore = ["E501"]
74
-
75
- [tool.ruff.format]
76
- quote-style = "double"
77
- indent-style = "space"
@@ -1,73 +0,0 @@
1
- from pymultirole_plugins.v1.schema import Annotation, Document
2
-
3
- from pyprocessors_nameparser.name_parser import NameParserParameters, NameParserProcessor
4
-
5
-
6
- def test_model():
7
- model = NameParserProcessor.get_model()
8
- model_class = model.model_construct().__class__
9
- assert model_class == NameParserParameters
10
-
11
-
12
- def test_nameparser():
13
- processor = NameParserProcessor()
14
- parameters = NameParserParameters(name_labels=["auteur"])
15
- doc = Document(
16
- text="Olivier Terrier",
17
- annotations=[Annotation(label="Auteur", labelName="auteur", start=0, end=15)],
18
- )
19
- docs = processor.process([doc], parameters)
20
- doc0 = docs[0]
21
- ot = doc0.annotations[0]
22
- assert len(ot.properties) > 0
23
-
24
-
25
- def test_nameparser_no_annotations():
26
- processor = NameParserProcessor()
27
- parameters = NameParserParameters(name_labels=["auteur"])
28
- doc = Document(text="Some text without annotations")
29
- docs = processor.process([doc], parameters)
30
- assert len(docs) == 1
31
- assert docs[0].annotations is None or len(docs[0].annotations) == 0
32
-
33
-
34
- def test_nameparser_non_matching_label():
35
- processor = NameParserProcessor()
36
- parameters = NameParserParameters(name_labels=["auteur"])
37
- doc = Document(
38
- text="Olivier Terrier",
39
- annotations=[Annotation(label="Location", labelName="location", start=0, end=15)],
40
- )
41
- docs = processor.process([doc], parameters)
42
- assert docs[0].annotations[0].properties is None or len(docs[0].annotations[0].properties) == 0
43
-
44
-
45
- def test_nameparser_multiple_annotations():
46
- processor = NameParserProcessor()
47
- parameters = NameParserParameters(name_labels=["auteur"])
48
- doc = Document(
49
- text="Olivier Terrier and John Smith",
50
- annotations=[
51
- Annotation(label="Auteur", labelName="auteur", start=0, end=15),
52
- Annotation(label="Auteur", labelName="auteur", start=20, end=30),
53
- ],
54
- )
55
- docs = processor.process([doc], parameters)
56
- doc0 = docs[0]
57
- assert len(doc0.annotations) == 2
58
- assert len(doc0.annotations[0].properties) > 0
59
- assert len(doc0.annotations[1].properties) > 0
60
-
61
-
62
- def test_nameparser_parsed_fields():
63
- processor = NameParserProcessor()
64
- parameters = NameParserParameters(name_labels=["auteur"])
65
- doc = Document(
66
- text="Dr. John A. Smith Jr.",
67
- annotations=[Annotation(label="Auteur", labelName="auteur", start=0, end=21)],
68
- )
69
- docs = processor.process([doc], parameters)
70
- props = docs[0].annotations[0].properties
71
- assert "title" in props
72
- assert "first" in props
73
- assert "last" in props
@@ -1,148 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
- {{- if . }}
6
- <style>
7
- * {
8
- font-family: Arial, Helvetica, sans-serif;
9
- }
10
- h1 {
11
- text-align: center;
12
- }
13
- .group-header th {
14
- font-size: 200%;
15
- }
16
- .sub-header th {
17
- font-size: 150%;
18
- }
19
- table, th, td {
20
- border: 1px solid black;
21
- border-collapse: collapse;
22
- white-space: nowrap;
23
- padding: .3em;
24
- }
25
- table {
26
- margin: 0 auto;
27
- }
28
- .severity {
29
- text-align: center;
30
- font-weight: bold;
31
- color: #fafafa;
32
- }
33
- .severity-LOW .severity { background-color: #5fbb31; }
34
- .severity-MEDIUM .severity { background-color: #e9c600; }
35
- .severity-HIGH .severity { background-color: #ff8800; }
36
- .severity-CRITICAL .severity { background-color: #e40000; }
37
- .severity-UNKNOWN .severity { background-color: #747474; }
38
- .severity-LOW { background-color: #5fbb3160; }
39
- .severity-MEDIUM { background-color: #e9c60060; }
40
- .severity-HIGH { background-color: #ff880060; }
41
- .severity-CRITICAL { background-color: #e4000060; }
42
- .severity-UNKNOWN { background-color: #74747460; }
43
- table tr td:first-of-type {
44
- font-weight: bold;
45
- }
46
- .links a,
47
- .links[data-more-links=on] a {
48
- display: block;
49
- }
50
- .links[data-more-links=off] a:nth-of-type(1n+5) {
51
- display: none;
52
- }
53
- a.toggle-more-links { cursor: pointer; }
54
- </style>
55
- <title>{{- escapeXML ( index . 0 ).Target }} - Trivy Report - {{ now }} </title>
56
- <script>
57
- window.onload = function() {
58
- document.querySelectorAll('td.links').forEach(function(linkCell) {
59
- var links = [].concat.apply([], linkCell.querySelectorAll('a'));
60
- [].sort.apply(links, function(a, b) {
61
- return a.href > b.href ? 1 : -1;
62
- });
63
- links.forEach(function(link, idx) {
64
- if (links.length > 3 && 3 === idx) {
65
- var toggleLink = document.createElement('a');
66
- toggleLink.innerText = "Toggle more links";
67
- toggleLink.href = "#toggleMore";
68
- toggleLink.setAttribute("class", "toggle-more-links");
69
- linkCell.appendChild(toggleLink);
70
- }
71
- linkCell.appendChild(link);
72
- });
73
- });
74
- document.querySelectorAll('a.toggle-more-links').forEach(function(toggleLink) {
75
- toggleLink.onclick = function() {
76
- var expanded = toggleLink.parentElement.getAttribute("data-more-links");
77
- toggleLink.parentElement.setAttribute("data-more-links", "on" === expanded ? "off" : "on");
78
- return false;
79
- };
80
- });
81
- };
82
- </script>
83
- </head>
84
- <body>
85
- <h1>{{- escapeXML ( index . 0 ).Target }} - Trivy Report - {{ now }}</h1>
86
- <table>
87
- {{- range . }}
88
- <tr class="group-header"><th colspan="6">{{ .Type | toString | escapeXML }}</th></tr>
89
- {{- if (eq (len .Vulnerabilities) 0) }}
90
- <tr><th colspan="6">No Vulnerabilities found</th></tr>
91
- {{- else }}
92
- <tr class="sub-header">
93
- <th>Package</th>
94
- <th>Vulnerability ID</th>
95
- <th>Severity</th>
96
- <th>Installed Version</th>
97
- <th>Fixed Version</th>
98
- <th>Links</th>
99
- </tr>
100
- {{- range .Vulnerabilities }}
101
- <tr class="severity-{{ escapeXML .Vulnerability.Severity }}">
102
- <td class="pkg-name">{{ escapeXML .PkgName }}</td>
103
- <td>{{ escapeXML .VulnerabilityID }}</td>
104
- <td class="severity">{{ escapeXML .Vulnerability.Severity }}</td>
105
- <td class="pkg-version">{{ escapeXML .InstalledVersion }}</td>
106
- <td>{{ escapeXML .FixedVersion }}</td>
107
- <td class="links" data-more-links="off">
108
- {{- range .Vulnerability.References }}
109
- <a href={{ escapeXML . | printf "%q" }}>{{ escapeXML . }}</a>
110
- {{- end }}
111
- </td>
112
- </tr>
113
- {{- end }}
114
- {{- end }}
115
- {{- if (eq (len .Misconfigurations ) 0) }}
116
- <tr><th colspan="6">No Misconfigurations found</th></tr>
117
- {{- else }}
118
- <tr class="sub-header">
119
- <th>Type</th>
120
- <th>Misconf ID</th>
121
- <th>Check</th>
122
- <th>Severity</th>
123
- <th>Message</th>
124
- </tr>
125
- {{- range .Misconfigurations }}
126
- <tr class="severity-{{ escapeXML .Severity }}">
127
- <td class="misconf-type">{{ escapeXML .Type }}</td>
128
- <td>{{ escapeXML .ID }}</td>
129
- <td class="misconf-check">{{ escapeXML .Title }}</td>
130
- <td class="severity">{{ escapeXML .Severity }}</td>
131
- <td class="link" data-more-links="off" style="white-space:normal;">
132
- {{ escapeXML .Message }}
133
- <br>
134
- <a href={{ escapeXML .PrimaryURL | printf "%q" }}>{{ escapeXML .PrimaryURL }}</a>
135
- </br>
136
- </td>
137
- </tr>
138
- {{- end }}
139
- {{- end }}
140
- {{- end }}
141
- </table>
142
- {{- else }}
143
- </head>
144
- <body>
145
- <h1>Trivy Returned Empty Report</h1>
146
- {{- end }}
147
- </body>
148
- </html>