Coverage for lode / helpers / formats.py: 90%

10 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-10-05 16:02 +0000

1# lode/helpers/formats.py 

2"""Semantic artefact format registry. 

3 

4Single source of truth for which formats exist and which are enabled. 

5Imported by both api.py and cli.py so the gate is enforced identically 

6in both entry points. 

7""" 

8from enum import Enum 

9from lode.exceptions import ArtefactValidationError 

10 

11# Formats enabled in this release. Add a value here when the reader 

12# and viewer for that format are stable and tested. 

13ENABLED_FORMATS = {"owl"} 

14 

15 

16class ReadAsFormat(str, Enum): 

17 """Semantic artefact type. Note: currently only `owl` is enabled.""" 

18 owl = "owl" 

19 rdf = "rdf" 

20 skos = "skos" 

21 

22 

23def check_format_enabled(read_as: "ReadAsFormat") -> None: 

24 """Raise ArtefactValidationError if the format is not yet available.""" 

25 if read_as.value not in ENABLED_FORMATS: 

26 raise ArtefactValidationError( 

27 f"Format '{read_as.value}' is not available yet", 

28 context={ 

29 "requested": read_as.value, 

30 "supported": sorted(ENABLED_FORMATS), 

31 }, 

32 )