sdb-reader 0.10.0__tar.gz → 0.11.0__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.
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/CHANGELOG.md +43 -0
- {sdb_reader-0.10.0/src/sdb_reader.egg-info → sdb_reader-0.11.0}/PKG-INFO +1 -1
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/pyproject.toml +1 -1
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/__init__.py +6 -2
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/compliance.py +162 -1
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/messages.py +5 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/messages_data/de.toml +5 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/messages_data/en.toml +5 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/parser.py +112 -5
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/read_record.schema.json +24 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/schema.py +3 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/serialise.py +9 -1
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/statements.py +51 -1
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/versions.py +1 -1
- {sdb_reader-0.10.0 → sdb_reader-0.11.0/src/sdb_reader.egg-info}/PKG-INFO +1 -1
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/LICENSE +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/MANIFEST.in +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/NOTICE +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/README.md +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/setup.cfg +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/ask.py +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/ask_record.schema.json +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/cli.py +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/clp_statements_de.json +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/current.py +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/diff.py +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/embedded.py +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/extraction.py +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/layout.py +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/line_breaks.py +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/model.py +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/pictograms.py +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/presets.py +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/presets.toml +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/py.typed +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/reading.py +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/scan.py +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/show.py +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader/verification.py +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader.egg-info/SOURCES.txt +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader.egg-info/dependency_links.txt +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader.egg-info/entry_points.txt +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader.egg-info/requires.txt +0 -0
- {sdb_reader-0.10.0 → sdb_reader-0.11.0}/src/sdb_reader.egg-info/top_level.txt +0 -0
|
@@ -5,6 +5,49 @@ Versions follow the tags of this repository.
|
|
|
5
5
|
|
|
6
6
|
## Unreleased
|
|
7
7
|
|
|
8
|
+
## 0.11.0 – 2026-11-21
|
|
9
|
+
|
|
10
|
+
### Breaking
|
|
11
|
+
|
|
12
|
+
- **`PARSER_VERSION` is 20** (0.10.0: 19): findings are part of the reading.
|
|
13
|
+
`EXTRACTION_VERSION` stays 2; readings kept from before should be made
|
|
14
|
+
again from the stored texts.
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- **Whether the label prints a statement's code.** Each statement of the
|
|
19
|
+
label says under `code_source` whether the sheet prints its code
|
|
20
|
+
(`printed`) or only its sentence, to which the parser assigned the code
|
|
21
|
+
(`from_wording`), and `hazard_statements.codes_from_wording` lists the
|
|
22
|
+
assigned codes. The code lists stay as they are. `as_printed(text,
|
|
23
|
+
codes_from_wording)` gives a statement text without the assigned codes,
|
|
24
|
+
as the sheet prints it (SDB-174).
|
|
25
|
+
- **A hazard statement of the classification that the label does not
|
|
26
|
+
carry.** Where section 2.1 names an H statement for the classification and
|
|
27
|
+
the label carries neither its code nor its wording, the sheet gets the
|
|
28
|
+
finding `hazard-statement-not-in-label` with the code. Not required are H400
|
|
29
|
+
beside H410 and H318 beside H314 (CLP Annex III Part 1) and H304 on an
|
|
30
|
+
aerosol (Annex I 1.3.3); not where the label carries no H statement at all,
|
|
31
|
+
which `label-without-hazard-statement` says (SDB-173).
|
|
32
|
+
- **Findings for the label of a classified product.** Where section 2
|
|
33
|
+
classifies the product under CLP and the label (2.2) is not found
|
|
34
|
+
(`label-not-found`), carries no H statement
|
|
35
|
+
(`label-without-hazard-statement`) or no P statement
|
|
36
|
+
(`label-without-precautionary-statement`), the sheet gets a finding. The
|
|
37
|
+
reading stays as the sheet prints it; nothing is added. Each finding says
|
|
38
|
+
"not found": the sheet may lack it, or the parser may have missed it. Not
|
|
39
|
+
for an article, a classification under the old law, or a label under the
|
|
40
|
+
directives before CLP on a sheet dated before 1 June 2015; the parser notes
|
|
41
|
+
such a label (`label-before-clp`) (SDB-169 to SDB-172).
|
|
42
|
+
|
|
43
|
+
### Fixed
|
|
44
|
+
|
|
45
|
+
- **A section heading numbered with a colon starts its section.** "3:
|
|
46
|
+
Zusammensetzung / Angaben zu den Bestandteilen" is the heading of section 3
|
|
47
|
+
as "3. Zusammensetzung …" is, when the title fits the number; before, section
|
|
48
|
+
2 ran on into section 3, and an ingredient's classification counted as the
|
|
49
|
+
product's (SDB-175).
|
|
50
|
+
|
|
8
51
|
## 0.10.0 – 2026-11-20
|
|
9
52
|
|
|
10
53
|
### Breaking
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sdb-reader
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0
|
|
4
4
|
Summary: Reads German safety data sheets (Sicherheitsdatenblätter) under REACH and CLP, without a language model
|
|
5
5
|
Author-email: "Förde-Baumarkt Holger Claussen GmbH & Co. KG" <service@foerde-baumarkt.de>
|
|
6
6
|
License-Expression: AGPL-3.0-or-later
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "sdb-reader"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.11.0"
|
|
8
8
|
description = "Reads German safety data sheets (Sicherheitsdatenblätter) under REACH and CLP, without a language model"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "Förde-Baumarkt Holger Claussen GmbH & Co. KG", email = "service@foerde-baumarkt.de" }]
|
|
@@ -28,8 +28,10 @@ with any release, the parts that ask a language model included.
|
|
|
28
28
|
- Judging a sheet: ``sheet_findings`` and the checks it is made of,
|
|
29
29
|
``classification`` and ``requires_sheet``.
|
|
30
30
|
- Statements and pictograms: ``label_statements`` with the regulation's
|
|
31
|
-
wording (``canonical_text``)
|
|
32
|
-
|
|
31
|
+
wording (``canonical_text``) and whether the label prints each code, the
|
|
32
|
+
statement texts tidied and rendered, ``as_printed`` for the texts without
|
|
33
|
+
the codes the label does not print, the pictograms that follow from H
|
|
34
|
+
statements.
|
|
33
35
|
- Embedded data: ``read_embedded``, ``parse_embedded`` and
|
|
34
36
|
``embedded_differences``.
|
|
35
37
|
- Messages: what the library notes about a file is a ``Message`` with a
|
|
@@ -90,6 +92,7 @@ from .serialise import (
|
|
|
90
92
|
)
|
|
91
93
|
from .statements import (
|
|
92
94
|
StatementWording,
|
|
95
|
+
as_printed,
|
|
93
96
|
canonical_text,
|
|
94
97
|
label_statements,
|
|
95
98
|
normalize_statements,
|
|
@@ -125,6 +128,7 @@ __all__ = [
|
|
|
125
128
|
"StatedClassification",
|
|
126
129
|
"StatementWording",
|
|
127
130
|
"Verification",
|
|
131
|
+
"as_printed",
|
|
128
132
|
"canonical_text",
|
|
129
133
|
"classification",
|
|
130
134
|
"contradicts_label",
|
|
@@ -18,11 +18,22 @@ from .messages import Message
|
|
|
18
18
|
from .parser import (
|
|
19
19
|
CLASSIFIED_BEFORE_CLP,
|
|
20
20
|
EUH_WORDING_OUTSIDE_LABEL,
|
|
21
|
+
LABEL_BEFORE_CLP,
|
|
22
|
+
LABEL_HEADING_PATTERN,
|
|
21
23
|
LABEL_UNDETERMINED,
|
|
24
|
+
NO_LABEL_SECTION,
|
|
22
25
|
SheetPart,
|
|
26
|
+
classification_hazard_codes,
|
|
23
27
|
)
|
|
24
28
|
from .schema import HazardStatements, SafetyDataSheet, Section, StatedClassification
|
|
25
|
-
from .statements import
|
|
29
|
+
from .statements import (
|
|
30
|
+
SHEET_ON_REQUEST,
|
|
31
|
+
_catalogue,
|
|
32
|
+
_comparable,
|
|
33
|
+
base_code,
|
|
34
|
+
deviates_from_regulation,
|
|
35
|
+
label_statements,
|
|
36
|
+
)
|
|
26
37
|
|
|
27
38
|
# Annex II of REACH in the version of Regulation (EU) 2020/878 applies from
|
|
28
39
|
# 1 January 2021; sheets not conforming to it could be supplied until
|
|
@@ -253,6 +264,152 @@ def contradicts_label(sheet: SafetyDataSheet) -> bool:
|
|
|
253
264
|
)
|
|
254
265
|
|
|
255
266
|
|
|
267
|
+
def label_not_found(
|
|
268
|
+
sheet: SafetyDataSheet, parser_warnings: Iterable[Message]
|
|
269
|
+
) -> list[Message]:
|
|
270
|
+
"""What the label of a product section 2 classifies should carry and the
|
|
271
|
+
parser did not find in it (SDB-169 to SDB-172).
|
|
272
|
+
|
|
273
|
+
The reading stays as it is: these are findings beside it, and each says
|
|
274
|
+
"not found", which is true whether the sheet lacks it or the parser missed
|
|
275
|
+
it. Only for a product classified under CLP (SDB-75); not under the old
|
|
276
|
+
law (SDB-73), not for a label under the old directives on a sheet dated
|
|
277
|
+
before 1 June 2015, and not for an article, which is not labelled under
|
|
278
|
+
CLP (SDB-142, SDB-154). A label counts as found where the parser found its
|
|
279
|
+
block (SDB-4), or, without one, read any element of a label in section 2.
|
|
280
|
+
|
|
281
|
+
>>> from sdb_reader import HazardStatements
|
|
282
|
+
>>> def sheet(label, stated=StatedClassification.CLASSIFIED):
|
|
283
|
+
... return SafetyDataSheet(
|
|
284
|
+
... None, None, None, None, "de", hazard_statements=label,
|
|
285
|
+
... stated_classification=stated,
|
|
286
|
+
... )
|
|
287
|
+
>>> [m.code for m in label_not_found(sheet(HazardStatements()),
|
|
288
|
+
... [Message(NO_LABEL_SECTION)])]
|
|
289
|
+
['label-not-found']
|
|
290
|
+
>>> [m.code for m in label_not_found(
|
|
291
|
+
... sheet(HazardStatements(signal_word="Achtung", precautionary_codes=["P210"])),
|
|
292
|
+
... [])]
|
|
293
|
+
['label-without-hazard-statement']
|
|
294
|
+
>>> label_not_found(sheet(HazardStatements(), StatedClassification.NOT_STATED), [])
|
|
295
|
+
[]
|
|
296
|
+
"""
|
|
297
|
+
noted = {warning.code for warning in parser_warnings}
|
|
298
|
+
if not _label_is_judged(sheet, noted):
|
|
299
|
+
return []
|
|
300
|
+
label = sheet.hazard_statements
|
|
301
|
+
read_any = bool(
|
|
302
|
+
label.hazard_codes
|
|
303
|
+
or label.precautionary_codes
|
|
304
|
+
or label.supplemental_codes
|
|
305
|
+
or label.signal_word
|
|
306
|
+
or label.pictograms
|
|
307
|
+
)
|
|
308
|
+
if NO_LABEL_SECTION in noted and not read_any:
|
|
309
|
+
return [Message("label-not-found")]
|
|
310
|
+
findings: list[Message] = []
|
|
311
|
+
if not label.hazard_codes:
|
|
312
|
+
findings.append(Message("label-without-hazard-statement"))
|
|
313
|
+
if not label.precautionary_codes:
|
|
314
|
+
findings.append(Message("label-without-precautionary-statement"))
|
|
315
|
+
return findings
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def _label_is_judged(sheet: SafetyDataSheet, noted: Collection[str]) -> bool:
|
|
319
|
+
"""Whether the label findings apply to *sheet* (SDB-170): a product
|
|
320
|
+
classified under CLP, no article, no classification under the old law, and
|
|
321
|
+
no label under the old directives on a sheet dated before 1 June 2015.
|
|
322
|
+
*noted* are the codes of the parser's warnings."""
|
|
323
|
+
if sheet.stated_classification is not StatedClassification.CLASSIFIED:
|
|
324
|
+
return False
|
|
325
|
+
if sheet.stated_article or CLASSIFIED_BEFORE_CLP in noted:
|
|
326
|
+
return False
|
|
327
|
+
# A mixture could be labelled under the old directives until 1 June 2015.
|
|
328
|
+
dated = sheet.revision_date or sheet.issue_date
|
|
329
|
+
return not (
|
|
330
|
+
LABEL_BEFORE_CLP in noted and dated is not None and dated < CLP_FOR_MIXTURES
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
# The order of precedence Annex III Part 1 sets under Article 27 (consolidated
|
|
335
|
+
# version of 1 July 2026): a statement the label may leave out beside another.
|
|
336
|
+
_LEFT_OUT_BESIDE = {"H400": "H410", "H318": "H314"}
|
|
337
|
+
# An aerosol: its class in 2.1 or one of its statements (Annex I 2.3).
|
|
338
|
+
_AEROSOL_CLASS = re.compile(r"\bAerosol\s?[123]\b")
|
|
339
|
+
_AEROSOL_STATEMENTS = frozenset({"H222", "H223", "H229"})
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def _not_required(
|
|
343
|
+
code: str, on_label: set[str], classified: set[str], hazards: str
|
|
344
|
+
) -> bool:
|
|
345
|
+
"""Whether the label may go without *code* although 2.1 names it (SDB-173).
|
|
346
|
+
|
|
347
|
+
Beside H410 or H314 the label may leave out H400 or H318 (CLP Annex III
|
|
348
|
+
Part 1 under Article 27). A product placed on the market as an aerosol need
|
|
349
|
+
not be labelled for the aspiration hazard, H304 (Annex I 1.3.3).
|
|
350
|
+
"""
|
|
351
|
+
if _LEFT_OUT_BESIDE.get(code) in on_label:
|
|
352
|
+
return True
|
|
353
|
+
return code == "H304" and bool(
|
|
354
|
+
_AEROSOL_CLASS.search(hazards) or (classified | on_label) & _AEROSOL_STATEMENTS
|
|
355
|
+
)
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
def hazard_statements_not_in_label(
|
|
359
|
+
sheet: SafetyDataSheet, parser_warnings: Iterable[Message]
|
|
360
|
+
) -> list[Message]:
|
|
361
|
+
r"""Each H statement of the classification in 2.1 that the label does not
|
|
362
|
+
carry (SDB-173), with its code as ``statement``.
|
|
363
|
+
|
|
364
|
+
Only where the label carries at least one H statement -- without any,
|
|
365
|
+
``label-without-hazard-statement`` says so (SDB-171) -- and with the
|
|
366
|
+
exceptions of SDB-170. A code counts as carried where the label carries the
|
|
367
|
+
same statement, H360 and H361 whatever their letters, and H400 and H318 also
|
|
368
|
+
where the label carries H410 or H314 (CLP Article 27 with Annex III Part 1).
|
|
369
|
+
|
|
370
|
+
>>> from sdb_reader import HazardStatements
|
|
371
|
+
>>> section = (
|
|
372
|
+
... "2.1 Einstufung des Stoffs oder Gemischs\n"
|
|
373
|
+
... "Aerosol 3, H229\nAquatic Acute 1, H400\nAquatic Chronic 1, H410\n"
|
|
374
|
+
... "2.2 Kennzeichnungselemente\n"
|
|
375
|
+
... )
|
|
376
|
+
>>> sheet = SafetyDataSheet(
|
|
377
|
+
... None, None, None, None, "de",
|
|
378
|
+
... hazard_statements=HazardStatements(hazard_codes=["H410"]),
|
|
379
|
+
... stated_classification=StatedClassification.CLASSIFIED,
|
|
380
|
+
... section_text={Section.HAZARDS: section},
|
|
381
|
+
... )
|
|
382
|
+
>>> [m.params["statement"] for m in hazard_statements_not_in_label(sheet, [])]
|
|
383
|
+
['H229']
|
|
384
|
+
"""
|
|
385
|
+
noted = {warning.code for warning in parser_warnings}
|
|
386
|
+
label = sheet.hazard_statements
|
|
387
|
+
if not label.hazard_codes or not _label_is_judged(sheet, noted):
|
|
388
|
+
return []
|
|
389
|
+
hazards = sheet.section_text.get(Section.HAZARDS, "")
|
|
390
|
+
heading = LABEL_HEADING_PATTERN.search(hazards)
|
|
391
|
+
label_text = _comparable(hazards[heading.start() :]) if heading else ""
|
|
392
|
+
on_label = {base_code(code) for code in label.hazard_codes}
|
|
393
|
+
# Without the wordings of its own statements: "Giftig für Wasserorganismen,
|
|
394
|
+
# mit langfristiger Wirkung" (H411) stands inside H410's.
|
|
395
|
+
wordings = _catalogue()
|
|
396
|
+
for code in on_label:
|
|
397
|
+
if own := wordings.get(code):
|
|
398
|
+
label_text = label_text.replace(_comparable(own), " ")
|
|
399
|
+
classified = {base_code(code) for code in classification_hazard_codes(hazards)}
|
|
400
|
+
missing: list[Message] = []
|
|
401
|
+
for code in sorted(classification_hazard_codes(hazards)):
|
|
402
|
+
base = base_code(code)
|
|
403
|
+
if base in on_label or _not_required(base, on_label, classified, hazards):
|
|
404
|
+
continue
|
|
405
|
+
# The label prints the statement's wording without its code.
|
|
406
|
+
wording = wordings.get(base)
|
|
407
|
+
if wording and _comparable(wording) in label_text:
|
|
408
|
+
continue
|
|
409
|
+
missing.append(Message("hazard-statement-not-in-label", {"statement": code}))
|
|
410
|
+
return missing
|
|
411
|
+
|
|
412
|
+
|
|
256
413
|
class Classification(StrEnum):
|
|
257
414
|
"""What a sheet's label states about the product's classification."""
|
|
258
415
|
|
|
@@ -468,6 +625,7 @@ def sheet_findings(
|
|
|
468
625
|
... "Verordnung (EG) Nr. 1907/2006\\n"
|
|
469
626
|
... "Signalwort: Achtung\\n"
|
|
470
627
|
... "H315: Verursacht Hautreizungen.\\n"
|
|
628
|
+
... "P280: Schutzhandschuhe tragen.\\n"
|
|
471
629
|
... )
|
|
472
630
|
>>> result = read_extraction(
|
|
473
631
|
... extraction_from_dict(
|
|
@@ -540,6 +698,9 @@ def sheet_findings(
|
|
|
540
698
|
if contradicts_label(sheet):
|
|
541
699
|
findings.append(Message("classification-contradicts-label"))
|
|
542
700
|
|
|
701
|
+
findings.extend(label_not_found(sheet, parser_warnings))
|
|
702
|
+
findings.extend(hazard_statements_not_in_label(sheet, parser_warnings))
|
|
703
|
+
|
|
543
704
|
findings.extend(
|
|
544
705
|
Message("euh-outside-label", dict(outside.params))
|
|
545
706
|
for outside in euh_outside_label(parser_warnings)
|
|
@@ -59,6 +59,7 @@ MESSAGE_CODES: Mapping[str, tuple[str, ...]] = {
|
|
|
59
59
|
"no-label-section": (),
|
|
60
60
|
"several-sheets": ("count",),
|
|
61
61
|
"classified-before-clp": ("basis",),
|
|
62
|
+
"label-before-clp": (),
|
|
62
63
|
"no-hazard-codes": (),
|
|
63
64
|
"label-undetermined": (),
|
|
64
65
|
"no-precautionary-codes": (),
|
|
@@ -84,6 +85,10 @@ MESSAGE_CODES: Mapping[str, tuple[str, ...]] = {
|
|
|
84
85
|
"old-format": ("revised",),
|
|
85
86
|
"classification-not-stated": (),
|
|
86
87
|
"classification-contradicts-label": (),
|
|
88
|
+
"label-not-found": (),
|
|
89
|
+
"label-without-hazard-statement": (),
|
|
90
|
+
"hazard-statement-not-in-label": ("statement",),
|
|
91
|
+
"label-without-precautionary-statement": (),
|
|
87
92
|
"different-products": ("products",),
|
|
88
93
|
"country-editions-differ": ("fields",),
|
|
89
94
|
"euh-outside-label": ("statement", "sentence"),
|
|
@@ -41,6 +41,7 @@ date = "%d.%m.%Y"
|
|
|
41
41
|
"line-too-long" = "{count} Zeilen mit mehr als 2.000 Zeichen wurden nicht gelesen, die längste mit {length} Zeichen; ein Blatt druckt keine so langen Zeilen."
|
|
42
42
|
"no-label-section" = "Abschnitt 2.2 (Kennzeichnungselemente) wurde nicht gefunden; stattdessen wurde der ganze Abschnitt 2 gelesen."
|
|
43
43
|
"several-sheets" = "Die Datei enthält {count} Sicherheitsdatenblätter; ihre Kennzeichnungen sind zusammengeführt."
|
|
44
|
+
"label-before-clp" = "Die Kennzeichnung (2.2) folgt den Richtlinien vor der CLP-Verordnung: ohne H-, P- und EUH-Code, mit R- oder S-Sätzen, einem Gefahrensymbol oder dem Verweis auf die EG-Richtlinien."
|
|
44
45
|
"classified-before-clp" = "Abschnitt 2 stuft nach den Richtlinien vor der CLP-Verordnung ein ({basis}); es wurde keine Kennzeichnung gelesen."
|
|
45
46
|
"no-hazard-codes" = "Die Kennzeichnung trägt keinen H-Satz."
|
|
46
47
|
"label-undetermined" = "Die Kennzeichnung sagt, die Einstufung sei nicht bestimmt; das Blatt nennt für das Produkt keine Kennzeichnung."
|
|
@@ -67,6 +68,10 @@ date = "%d.%m.%Y"
|
|
|
67
68
|
"old-format" = "Überarbeitet am {revised}, aber aufgebaut wie vor der Verordnung (EU) 2020/878: keine endokrinschädlichen Eigenschaften, kein Unterabschnitt 11.2, kein Unterabschnitt 12.7."
|
|
68
69
|
"classification-not-stated" = "Abschnitt 2 nennt weder eine Gefahrenklasse noch sagt er, das Produkt sei nicht eingestuft, und die Kennzeichnung trägt weder H-Satz noch Signalwort noch Piktogramm."
|
|
69
70
|
"classification-contradicts-label" = "Abschnitt 2 nennt das Produkt nicht eingestuft, und die Kennzeichnung trägt einen H-Satz, ein Signalwort oder ein Piktogramm: Das Blatt widerspricht sich, oder eine der beiden Stellen ist falsch gelesen."
|
|
71
|
+
"label-not-found" = "Abschnitt 2 stuft das Produkt ein, und eine Kennzeichnung (2.2) wurde nicht gefunden; Anhang II der REACH-Verordnung verlangt sie dort."
|
|
72
|
+
"label-without-hazard-statement" = "Abschnitt 2 stuft das Produkt ein, und in der Kennzeichnung wurde kein H-Satz gefunden; die Einstufung verlangt ihre Gefahrenhinweise auf dem Etikett (CLP Art. 27)."
|
|
73
|
+
"label-without-precautionary-statement" = "Abschnitt 2 stuft das Produkt ein, und in der Kennzeichnung wurde kein P-Satz gefunden; die Einstufung verlangt die einschlägigen Sicherheitshinweise auf dem Etikett (CLP Art. 22)."
|
|
74
|
+
"hazard-statement-not-in-label" = "Abschnitt 2.1 nennt {statement} zur Einstufung, und in der Kennzeichnung wurde der Satz nicht gefunden; die Einstufung verlangt ihn auf dem Etikett (CLP Art. 27)."
|
|
70
75
|
"different-products" = "Die Datei enthält Sicherheitsdatenblätter verschiedener Produkte: {products}"
|
|
71
76
|
"country-editions-differ" = "Die Blätter desselben Produkts für verschiedene Länder weichen voneinander ab: {fields}"
|
|
72
77
|
"euh-outside-label" = "{statement} steht nur außerhalb der Kennzeichnung: {sentence}"
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"line-too-long" = "{count} lines of more than 2,000 characters were not read, the longest with {length}; a sheet prints no lines that long."
|
|
37
37
|
"no-label-section" = "Section 2.2 (Kennzeichnungselemente) was not found; the whole of section 2 was read instead."
|
|
38
38
|
"several-sheets" = "The file holds {count} safety data sheets; their labels are combined."
|
|
39
|
+
"label-before-clp" = "The label (2.2) follows the directives before the CLP Regulation: no H, P or EUH code, but R or S phrases, a hazard symbol or a reference to the EC directives."
|
|
39
40
|
"classified-before-clp" = "Section 2 classifies under the directives before CLP ({basis}); no label was read."
|
|
40
41
|
"no-hazard-codes" = "The label carries no H statement."
|
|
41
42
|
"label-undetermined" = "The label says that the classification was not determined; the sheet states no labelling for the product."
|
|
@@ -62,6 +63,10 @@
|
|
|
62
63
|
"old-format" = "Revised {revised}, but laid out as before Regulation (EU) 2020/878: no endocrine-disrupting properties, no subsection 11.2, no subsection 12.7."
|
|
63
64
|
"classification-not-stated" = "Section 2 neither names a hazard class nor says that the product is not classified, and the label carries no H statement, signal word or pictogram."
|
|
64
65
|
"classification-contradicts-label" = "Section 2 says the product is not classified, and the label carries an H statement, a signal word or a pictogram: the sheet contradicts itself, or one of the two was read wrongly."
|
|
66
|
+
"label-not-found" = "Section 2 classifies the product, and no label (2.2) was found; Annex II of REACH requires it there."
|
|
67
|
+
"label-without-hazard-statement" = "Section 2 classifies the product, and no H statement was found in the label; the classification requires its hazard statements on the label (CLP Article 27)."
|
|
68
|
+
"label-without-precautionary-statement" = "Section 2 classifies the product, and no P statement was found in the label; the classification requires the relevant precautionary statements on the label (CLP Article 22)."
|
|
69
|
+
"hazard-statement-not-in-label" = "Section 2.1 names {statement} for the classification, and the statement was not found in the label; the classification requires it on the label (CLP Article 27)."
|
|
65
70
|
"different-products" = "The file holds safety data sheets of different products: {products}"
|
|
66
71
|
"country-editions-differ" = "The sheets of the same product for different countries differ in: {fields}"
|
|
67
72
|
"euh-outside-label" = "{statement} is printed only outside the label: {sentence}"
|
|
@@ -50,6 +50,10 @@ LABEL_UNDETERMINED = "label-undetermined"
|
|
|
50
50
|
LABEL_LINE_UNASSIGNED = "label-line-unassigned"
|
|
51
51
|
EUH_WORDING_OUTSIDE_LABEL = "euh-wording-outside-label"
|
|
52
52
|
CLASSIFIED_BEFORE_CLP = "classified-before-clp"
|
|
53
|
+
# No block "2.2 Kennzeichnungselemente" was found in section 2 (SDB-4).
|
|
54
|
+
NO_LABEL_SECTION = "no-label-section"
|
|
55
|
+
# The label block follows the directives before CLP (SDB-170).
|
|
56
|
+
LABEL_BEFORE_CLP = "label-before-clp"
|
|
53
57
|
STATEMENT_TOO_LONG = "statement-too-long"
|
|
54
58
|
# How many lines a statement of the hint texts spans at most (SDB-168): the
|
|
55
59
|
# longest a sheet of the measured collection prints has 37.
|
|
@@ -179,9 +183,10 @@ SUBSECTION_TITLES: dict[int, re.Pattern[str]] = {
|
|
|
179
183
|
# The dot after the number is optional: "3 Zusammensetzung" is as common as
|
|
180
184
|
# "3. Zusammensetzung", and both are headings. Section numbers stop at 16.
|
|
181
185
|
# A mark for a changed section may stand in front (SDB-152): "* 1 Bezeichnung
|
|
182
|
-
# des …", "! 2. Mögliche Gefahren".
|
|
186
|
+
# des …", "! 2. Mögliche Gefahren". A colon may stand for the dot (SDB-175):
|
|
187
|
+
# "3: Zusammensetzung / Angaben zu den Bestandteilen".
|
|
183
188
|
NUMBERED_SECTION_PATTERN = re.compile(
|
|
184
|
-
r"^(?:[*!]\s*)?0?(1[0-6]|[1-9])\s
|
|
189
|
+
r"^(?:[*!]\s*)?0?(1[0-6]|[1-9])\s*[.:]?\s+(\S.{3,79}?)\s*$"
|
|
185
190
|
)
|
|
186
191
|
# Suppliers state the document's own version several ways: "Version 8.2",
|
|
187
192
|
# "Version: 1.1", "Versionsnummer 1", "Nummer der Fassung: 1.0" and
|
|
@@ -601,6 +606,32 @@ _HAZARD_DESIGNATION = re.compile(
|
|
|
601
606
|
_CLP_CODE_PRINTED = re.compile(r"\b(?:[HP][^\S\n]?\d{3}|EUH[^\S\n]?\d{3})\b")
|
|
602
607
|
|
|
603
608
|
|
|
609
|
+
# A label under the directives before CLP names them as its basis: "Kennzeichnung
|
|
610
|
+
# nach EWG-Richtlinien", "nach EG-Richtlinien/GefStoffV nicht
|
|
611
|
+
# kennzeichnungspflichtig", "gemäß 1999/45/EG".
|
|
612
|
+
_OLD_RULES_LABEL = re.compile(
|
|
613
|
+
r"\b(?:EWG|EG)-Richtlinien\b|67/548|(?:19)?99/45|\bGefStoffV\b", re.IGNORECASE
|
|
614
|
+
)
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
def label_before_clp(label: str) -> bool:
|
|
618
|
+
"""Whether a label block follows the directives before CLP (SDB-170).
|
|
619
|
+
|
|
620
|
+
It prints no H, P or EUH code, and either names the old directives as its
|
|
621
|
+
basis or labels with R phrases or a hazard symbol as SDB-73 reads them.
|
|
622
|
+
|
|
623
|
+
>>> label_before_clp("Kennzeichnung nach EWG-Richtlinien:\\nnicht kennzeichnungspflichtig.")
|
|
624
|
+
True
|
|
625
|
+
>>> label_before_clp("Kennzeichnung nach EWG-Richtlinien\\nH315 Verursacht Hautreizungen.")
|
|
626
|
+
False
|
|
627
|
+
>>> label_before_clp("Signalwort: Achtung")
|
|
628
|
+
False
|
|
629
|
+
"""
|
|
630
|
+
if _CLP_CODE_PRINTED.search(label):
|
|
631
|
+
return False
|
|
632
|
+
return bool(_OLD_RULES_LABEL.search(label)) or old_classification(label) is not None
|
|
633
|
+
|
|
634
|
+
|
|
604
635
|
def old_classification(hazards_section: str) -> str | None:
|
|
605
636
|
"""What section 2 classifies with under the rules before CLP, else None (SDB-73)."""
|
|
606
637
|
if _CLP_CODE_PRINTED.search(hazards_section):
|
|
@@ -794,6 +825,43 @@ def _gives_no_answer(part: str) -> bool:
|
|
|
794
825
|
return found > 0 and not re.search(r"[^\W\d]", rest)
|
|
795
826
|
|
|
796
827
|
|
|
828
|
+
# A hazard statement's code as section 2.1 names it with a hazard class: H200
|
|
829
|
+
# to H499, H360 and H361 with the letters of their effect (SDB-173).
|
|
830
|
+
_CLASSIFICATION_HAZARD_CODE = re.compile(
|
|
831
|
+
r"\bH(?:36[01][A-Za-z]{1,2}(?![^\W\d_])|[2-4]\d{2})(?!\d)"
|
|
832
|
+
)
|
|
833
|
+
|
|
834
|
+
|
|
835
|
+
def classification_hazard_codes(hazards_section: str) -> set[str]:
|
|
836
|
+
r"""The H codes section 2.1 names for the product's classification (SDB-173).
|
|
837
|
+
|
|
838
|
+
Read from the text under each classification heading up to the label's
|
|
839
|
+
(SDB-75); never codes of the sheet. A code on a line that speaks of
|
|
840
|
+
ingredients ("enthält", "Inhaltsstoff", "Bestandteil", as in SDB-80), or on
|
|
841
|
+
the line after one that it continues, is an ingredient's, not the product's.
|
|
842
|
+
|
|
843
|
+
>>> classification_hazard_codes(
|
|
844
|
+
... "2.1 Einstufung des Stoffs oder Gemischs\n"
|
|
845
|
+
... "Flam. Liq. 3, H226\nRepr. 1B, H360D\n"
|
|
846
|
+
... "Das Gemisch enthält Stoffe, die als Acute Tox. 4\n(H302) eingestuft sind.\n"
|
|
847
|
+
... "2.2 Kennzeichnungselemente\nH226 Flüssigkeit und Dampf entzündbar.\n"
|
|
848
|
+
... ) == {"H226", "H360D"}
|
|
849
|
+
True
|
|
850
|
+
"""
|
|
851
|
+
codes: set[str] = set()
|
|
852
|
+
for part in _classification_parts(hazards_section):
|
|
853
|
+
lines = part.split("\n")
|
|
854
|
+
for index, line in enumerate(lines):
|
|
855
|
+
found = _CLASSIFICATION_HAZARD_CODE.findall(line)
|
|
856
|
+
if not found or _ABOUT_INGREDIENTS.search(line):
|
|
857
|
+
continue
|
|
858
|
+
continues = line.lstrip()[:1].islower() or line.lstrip().startswith("(")
|
|
859
|
+
if continues and index and _ABOUT_INGREDIENTS.search(lines[index - 1]):
|
|
860
|
+
continue
|
|
861
|
+
codes.update(lettered_code(code) for code in found)
|
|
862
|
+
return codes
|
|
863
|
+
|
|
864
|
+
|
|
797
865
|
def stated_classification(hazards_section: str) -> StatedClassification:
|
|
798
866
|
"""What section 2 says about the product's classification (SDB-75).
|
|
799
867
|
|
|
@@ -1341,8 +1409,9 @@ class SDSParser:
|
|
|
1341
1409
|
def read_numbered_section_heading(line: str) -> int | None:
|
|
1342
1410
|
"""Return the section number of a plainly numbered heading, else None.
|
|
1343
1411
|
|
|
1344
|
-
Recognises "2. Mögliche Gefahren"
|
|
1345
|
-
that carry no "Abschnitt" for SECTION_HEADER_PATTERN
|
|
1412
|
+
Recognises "2. Mögliche Gefahren", "2: Mögliche Gefahren" and "2 Mögliche
|
|
1413
|
+
Gefahren", the forms that carry no "Abschnitt" for SECTION_HEADER_PATTERN
|
|
1414
|
+
to find. The title must
|
|
1346
1415
|
agree with the number: see SECTION_TITLE_PATTERNS for why the number alone
|
|
1347
1416
|
is not enough.
|
|
1348
1417
|
"""
|
|
@@ -1979,9 +2048,11 @@ def _parse_hazard_statements(
|
|
|
1979
2048
|
]
|
|
1980
2049
|
labels = [label for _, label in labelled]
|
|
1981
2050
|
if not labels and full_text:
|
|
1982
|
-
warnings.append(Message(
|
|
2051
|
+
warnings.append(Message(NO_LABEL_SECTION))
|
|
1983
2052
|
if len(labels) > 1:
|
|
1984
2053
|
warnings.append(Message("several-sheets", {"count": len(labels)}))
|
|
2054
|
+
if labels and all(label_before_clp(label) for label in labels):
|
|
2055
|
+
warnings.append(Message(LABEL_BEFORE_CLP))
|
|
1985
2056
|
|
|
1986
2057
|
# Each sheet's label is read as if it stood alone, then the product carries
|
|
1987
2058
|
# all of them. A combination pack holds both products, so it carries both
|
|
@@ -2045,6 +2116,18 @@ def _parse_hazard_statements(
|
|
|
2045
2116
|
signal_word=_strongest_signal_word(r.signal_word for r in readings),
|
|
2046
2117
|
pictograms=sorted(set().union(*(r.pictograms for r in readings))),
|
|
2047
2118
|
)
|
|
2119
|
+
# A code one sheet's label prints is printed, even where another sheet of
|
|
2120
|
+
# the file only prints its sentence (SDB-174).
|
|
2121
|
+
printed_somewhere = set().union(
|
|
2122
|
+
*(
|
|
2123
|
+
(r.hazard_codes | r.precautionary_codes | r.supplemental) - r.from_wording
|
|
2124
|
+
for r in readings
|
|
2125
|
+
)
|
|
2126
|
+
)
|
|
2127
|
+
from_wording = (
|
|
2128
|
+
set().union(*(r.from_wording for r in readings))
|
|
2129
|
+
| {code for code, _ in worded_supplemental}
|
|
2130
|
+
) - printed_somewhere
|
|
2048
2131
|
# The text has to say what the codes say. The codes are read off the label;
|
|
2049
2132
|
# the text is cut from the whole hazards section, which also holds 2.1's
|
|
2050
2133
|
# classification and, where a heading goes unread, the section 3 ingredient
|
|
@@ -2119,6 +2202,12 @@ def _parse_hazard_statements(
|
|
|
2119
2202
|
supplemental.add(code.group(0).upper())
|
|
2120
2203
|
supplemental_text = "\n".join(kept) or None
|
|
2121
2204
|
hazard_statements.supplemental_codes = sorted(supplemental)
|
|
2205
|
+
# A code kept by its wording here is printed in the text (SDB-124).
|
|
2206
|
+
from_wording -= {
|
|
2207
|
+
code.group(0).upper()
|
|
2208
|
+
for line in kept
|
|
2209
|
+
if (code := SUPPLEMENTAL_CODE_PATTERN.match(line)) is not None
|
|
2210
|
+
}
|
|
2122
2211
|
if supplemental_text:
|
|
2123
2212
|
supplemental_text = _with_substances_before_the_code(
|
|
2124
2213
|
supplemental_text, sections.get(Section.HAZARDS, "")
|
|
@@ -2139,6 +2228,12 @@ def _parse_hazard_statements(
|
|
|
2139
2228
|
)
|
|
2140
2229
|
or None
|
|
2141
2230
|
)
|
|
2231
|
+
on_label = {
|
|
2232
|
+
*hazard_statements.hazard_codes,
|
|
2233
|
+
*hazard_statements.precautionary_codes,
|
|
2234
|
+
*hazard_statements.supplemental_codes,
|
|
2235
|
+
}
|
|
2236
|
+
hazard_statements.codes_from_wording = sorted(from_wording & on_label)
|
|
2142
2237
|
_without_trailing_pictograms(hazard_statements)
|
|
2143
2238
|
warnings.extend(Message(STATEMENT_TOO_LONG, {"codes": codes}) for codes in too_long)
|
|
2144
2239
|
# What the label holds that nothing above read (SDB-165): a measure of
|
|
@@ -2514,6 +2609,9 @@ class _LabelReading:
|
|
|
2514
2609
|
# The sheet's sentence read as P501 by SDB-166, where the label prints no
|
|
2515
2610
|
# P501 code.
|
|
2516
2611
|
disposal: str | None = None
|
|
2612
|
+
# The codes the parser assigned to sentences the label prints without
|
|
2613
|
+
# them (SDB-174): SDB-6, SDB-28, SDB-163, SDB-166.
|
|
2614
|
+
from_wording: set[str] = field(default_factory=set)
|
|
2517
2615
|
|
|
2518
2616
|
|
|
2519
2617
|
def _strongest_signal_word(words: Iterable[str | None]) -> str | None:
|
|
@@ -2593,6 +2691,9 @@ def _read_label(
|
|
|
2593
2691
|
hazard_section_text = _LABEL_DECLINED.sub("", hazard_section_text)
|
|
2594
2692
|
|
|
2595
2693
|
hazard_codes = sorted(printed_hazard_codes(hazard_section_text))
|
|
2694
|
+
# Which list came from the sentences rather than printed codes (SDB-174).
|
|
2695
|
+
hazard_by_wording = False
|
|
2696
|
+
precautionary_by_wording: set[str] = set()
|
|
2596
2697
|
if not hazard_codes and classification is not None:
|
|
2597
2698
|
hazard_codes = sorted(
|
|
2598
2699
|
{lettered_code(code) for code in LABEL_HAZARD_CODE.findall(classification)}
|
|
@@ -2623,6 +2724,7 @@ def _read_label(
|
|
|
2623
2724
|
# "H", not "not EUH": EUH statements have their own field, and P
|
|
2624
2725
|
# statements are somebody else's list entirely.
|
|
2625
2726
|
hazard_codes = sorted(c for c in by_wording if c.startswith("H"))
|
|
2727
|
+
hazard_by_wording = bool(hazard_codes)
|
|
2626
2728
|
if not precautionary_codes:
|
|
2627
2729
|
by_variants: set[str] = set()
|
|
2628
2730
|
# And in the forms Annex IV allows for its choices, details and
|
|
@@ -2639,6 +2741,7 @@ def _read_label(
|
|
|
2639
2741
|
precautionary_codes = sorted(
|
|
2640
2742
|
{c for c in by_wording if c.startswith("P")} | by_variants
|
|
2641
2743
|
)
|
|
2744
|
+
precautionary_by_wording = set(precautionary_codes)
|
|
2642
2745
|
# P501 by the words many suppliers use for it, also beside other P codes
|
|
2643
2746
|
# (SDB-166); never on a label by the rules before CLP (SDB-120).
|
|
2644
2747
|
disposal = None
|
|
@@ -2653,6 +2756,7 @@ def _read_label(
|
|
|
2653
2756
|
disposal = _disposal_sentence(hazard_section_text)
|
|
2654
2757
|
if disposal is not None:
|
|
2655
2758
|
precautionary_codes = sorted({*precautionary_codes, "P501"})
|
|
2759
|
+
precautionary_by_wording.add("P501")
|
|
2656
2760
|
supplemental = sorted(
|
|
2657
2761
|
set(
|
|
2658
2762
|
code.upper()
|
|
@@ -2713,6 +2817,9 @@ def _read_label(
|
|
|
2713
2817
|
pictograms=set(pictograms),
|
|
2714
2818
|
warnings=warnings,
|
|
2715
2819
|
disposal=disposal,
|
|
2820
|
+
from_wording=(h_code_set if hazard_by_wording else set())
|
|
2821
|
+
| precautionary_by_wording
|
|
2822
|
+
| {code for code, _ in worded_supplemental},
|
|
2716
2823
|
)
|
|
2717
2824
|
|
|
2718
2825
|
|
|
@@ -362,6 +362,13 @@
|
|
|
362
362
|
"string",
|
|
363
363
|
"null"
|
|
364
364
|
]
|
|
365
|
+
},
|
|
366
|
+
"codes_from_wording": {
|
|
367
|
+
"type": "array",
|
|
368
|
+
"items": {
|
|
369
|
+
"type": "string"
|
|
370
|
+
},
|
|
371
|
+
"description": "The codes the label does not print and the parser assigned to the sentences it prints (SDB-174); each also stands in its list. Missing in a reading stored before."
|
|
365
372
|
}
|
|
366
373
|
}
|
|
367
374
|
},
|
|
@@ -460,6 +467,14 @@
|
|
|
460
467
|
"null"
|
|
461
468
|
],
|
|
462
469
|
"description": "The wording of the CLP Regulation, where it has exactly one."
|
|
470
|
+
},
|
|
471
|
+
"code_source": {
|
|
472
|
+
"type": "string",
|
|
473
|
+
"enum": [
|
|
474
|
+
"printed",
|
|
475
|
+
"from_wording"
|
|
476
|
+
],
|
|
477
|
+
"description": "Whether the label prints the code, or prints only the sentence and the parser assigned the code (SDB-174)."
|
|
463
478
|
}
|
|
464
479
|
}
|
|
465
480
|
},
|
|
@@ -509,6 +524,10 @@
|
|
|
509
524
|
"old-format",
|
|
510
525
|
"classification-not-stated",
|
|
511
526
|
"classification-contradicts-label",
|
|
527
|
+
"label-not-found",
|
|
528
|
+
"label-without-hazard-statement",
|
|
529
|
+
"label-without-precautionary-statement",
|
|
530
|
+
"hazard-statement-not-in-label",
|
|
512
531
|
"different-products",
|
|
513
532
|
"country-editions-differ",
|
|
514
533
|
"euh-outside-label",
|
|
@@ -683,9 +702,14 @@
|
|
|
683
702
|
"embedded-wrong-root",
|
|
684
703
|
"euh-outside-label",
|
|
685
704
|
"euh-wording-outside-label",
|
|
705
|
+
"label-before-clp",
|
|
686
706
|
"label-line-unassigned",
|
|
707
|
+
"label-not-found",
|
|
687
708
|
"statement-too-long",
|
|
688
709
|
"label-undetermined",
|
|
710
|
+
"label-without-hazard-statement",
|
|
711
|
+
"label-without-precautionary-statement",
|
|
712
|
+
"hazard-statement-not-in-label",
|
|
689
713
|
"leaflet-title",
|
|
690
714
|
"line-too-long",
|
|
691
715
|
"model-answer-unreadable",
|
|
@@ -41,6 +41,9 @@ class HazardStatements:
|
|
|
41
41
|
hazard_text: str | None = None
|
|
42
42
|
precautionary_text: str | None = None
|
|
43
43
|
supplemental_text: str | None = None
|
|
44
|
+
# The codes the label does not print and the parser assigned to the
|
|
45
|
+
# sentences it prints (SDB-174); every one of them also stands in its list.
|
|
46
|
+
codes_from_wording: list[str] = field(default_factory=list)
|
|
44
47
|
|
|
45
48
|
|
|
46
49
|
@dataclass(slots=True)
|
|
@@ -90,6 +90,7 @@ def _sheet_fields(sheet: SafetyDataSheet, content_hash: str | None) -> dict[str,
|
|
|
90
90
|
"hazard_text": sheet.hazard_statements.hazard_text,
|
|
91
91
|
"precautionary_text": sheet.hazard_statements.precautionary_text,
|
|
92
92
|
"supplemental_text": sheet.hazard_statements.supplemental_text,
|
|
93
|
+
"codes_from_wording": sheet.hazard_statements.codes_from_wording,
|
|
93
94
|
},
|
|
94
95
|
"contact_info": {
|
|
95
96
|
"supplier_name": sheet.contact_info.supplier_name,
|
|
@@ -163,6 +164,8 @@ def sheet_from_dict(stored: Mapping[str, Any]) -> SafetyDataSheet:
|
|
|
163
164
|
hazard_text=_optional_text(label["hazard_text"]),
|
|
164
165
|
precautionary_text=_optional_text(label["precautionary_text"]),
|
|
165
166
|
supplemental_text=_optional_text(label["supplemental_text"]),
|
|
167
|
+
# Not in a reading stored before SDB-174.
|
|
168
|
+
codes_from_wording=_texts(label.get("codes_from_wording", [])),
|
|
166
169
|
),
|
|
167
170
|
contact_info=ContactInfo(
|
|
168
171
|
supplier_name=_optional_text(contact["supplier_name"]),
|
|
@@ -308,7 +311,12 @@ def reading_to_dict(
|
|
|
308
311
|
def _statements(sheet: SafetyDataSheet) -> list[dict[str, Any]]:
|
|
309
312
|
"""The label's statements, each with both wordings (SDW-5)."""
|
|
310
313
|
return [
|
|
311
|
-
{
|
|
314
|
+
{
|
|
315
|
+
"code": s.code,
|
|
316
|
+
"sheet": s.sheet,
|
|
317
|
+
"regulation": s.regulation,
|
|
318
|
+
"code_source": s.code_source,
|
|
319
|
+
}
|
|
312
320
|
for s in label_statements(sheet.hazard_statements)
|
|
313
321
|
]
|
|
314
322
|
|
|
@@ -1041,6 +1041,50 @@ class StatementWording:
|
|
|
1041
1041
|
sheet: str | None
|
|
1042
1042
|
# None where the regulation gives the code no single wording.
|
|
1043
1043
|
regulation: str | None
|
|
1044
|
+
# PRINTED where the label prints the code, FROM_WORDING where it prints
|
|
1045
|
+
# only the sentence and the parser assigned the code (SDB-174).
|
|
1046
|
+
code_source: str = "printed"
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
PRINTED = "printed"
|
|
1050
|
+
FROM_WORDING = "from_wording"
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
def _assigned(code: str, from_wording: Collection[str]) -> bool:
|
|
1054
|
+
"""Whether every code of *code* ("P305+P351+P338" counts as its parts)
|
|
1055
|
+
is one the parser assigned to a sentence (SDB-174)."""
|
|
1056
|
+
return all(part in from_wording for part in code.split("+"))
|
|
1057
|
+
|
|
1058
|
+
|
|
1059
|
+
def as_printed(text: str | None, codes_from_wording: Collection[str]) -> str | None:
|
|
1060
|
+
r"""*text* with the codes the label does not print taken off its lines (SDB-174).
|
|
1061
|
+
|
|
1062
|
+
A line whose leading code -- every part of a combination -- the parser
|
|
1063
|
+
assigned to the sheet's sentence keeps the sentence and loses the code;
|
|
1064
|
+
every other line stays as it is.
|
|
1065
|
+
|
|
1066
|
+
>>> as_printed(
|
|
1067
|
+
... "P280: Schutzhandschuhe tragen.\nP501 Inhalt/Behälter … entsorgen",
|
|
1068
|
+
... ["P501"],
|
|
1069
|
+
... )
|
|
1070
|
+
'P280: Schutzhandschuhe tragen.\nInhalt/Behälter … entsorgen'
|
|
1071
|
+
>>> as_printed("EUH208: Enthält Musterol. Kann allergische Reaktionen "
|
|
1072
|
+
... "hervorrufen.", ["EUH208"])
|
|
1073
|
+
'Enthält Musterol. Kann allergische Reaktionen hervorrufen.'
|
|
1074
|
+
>>> as_printed("P305+P351+P338: BEI KONTAKT MIT DEN AUGEN: …", ["P338"])
|
|
1075
|
+
'P305+P351+P338: BEI KONTAKT MIT DEN AUGEN: …'
|
|
1076
|
+
"""
|
|
1077
|
+
if not text or not codes_from_wording:
|
|
1078
|
+
return text
|
|
1079
|
+
lines = []
|
|
1080
|
+
for line in text.split("\n"):
|
|
1081
|
+
statement = STATEMENT_LINE.match(line)
|
|
1082
|
+
if statement is not None and statement.group(4).strip():
|
|
1083
|
+
code = re.sub(r"\s*\+\s*", "+", statement.group(2))
|
|
1084
|
+
if _assigned(code.upper(), codes_from_wording):
|
|
1085
|
+
line = statement.group(1) + statement.group(4).strip()
|
|
1086
|
+
lines.append(line)
|
|
1087
|
+
return "\n".join(lines)
|
|
1044
1088
|
|
|
1045
1089
|
|
|
1046
1090
|
# Codes standing first in a wording: the rest of a row of codes joined by
|
|
@@ -1112,8 +1156,14 @@ def label_statements(hazards: HazardStatements) -> list[StatementWording]:
|
|
|
1112
1156
|
|
|
1113
1157
|
for code in sorted(on_label - {part for c in wordings for part in c.split("+")}):
|
|
1114
1158
|
add(code, None)
|
|
1159
|
+
assigned = set(hazards.codes_from_wording)
|
|
1115
1160
|
return [
|
|
1116
|
-
StatementWording(
|
|
1161
|
+
StatementWording(
|
|
1162
|
+
code,
|
|
1163
|
+
wording,
|
|
1164
|
+
canonical_text(code),
|
|
1165
|
+
FROM_WORDING if assigned and _assigned(code, assigned) else PRINTED,
|
|
1166
|
+
)
|
|
1117
1167
|
for code, printed in wordings.items()
|
|
1118
1168
|
for wording in (printed or (None,))
|
|
1119
1169
|
]
|
|
@@ -19,7 +19,7 @@ EXTRACTION_VERSION = 2
|
|
|
19
19
|
# Raise when the same text can give another reading: the verdict, the parser,
|
|
20
20
|
# the statements and their tables, the findings, the message codes, the JSON
|
|
21
21
|
# form. The sentences of the catalogs are no part of a reading.
|
|
22
|
-
PARSER_VERSION =
|
|
22
|
+
PARSER_VERSION = 20
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
def extraction_stage() -> str:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sdb-reader
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.11.0
|
|
4
4
|
Summary: Reads German safety data sheets (Sicherheitsdatenblätter) under REACH and CLP, without a language model
|
|
5
5
|
Author-email: "Förde-Baumarkt Holger Claussen GmbH & Co. KG" <service@foerde-baumarkt.de>
|
|
6
6
|
License-Expression: AGPL-3.0-or-later
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|