Coverage for src/indium/__init__.py: 100%

1"""Elemental Indium: Text inspection, invisible characters, and integrity validation.

2

3 Zero-dependency Python library for:

4- Detecting and sanitizing invisible characters

5- Detecting visual spoofing via homoglyphs

6- Safe grapheme-aware text operations

7

8 Modules:

9 invisibles: Reveal and sanitize invisible characters

10 spoofing: Detect homoglyphs and mixed scripts

11 segments: Grapheme-aware text slicing

12

13 Example:

14 >>> import indium

15 >>> indium.sanitize("hello\\u200Bworld")

16 'helloworld'

17 >>> indium.skeleton("pаypal") # Cyrillic 'а'

18 'paypal'

19 >>> indium.safe_truncate("👨‍👩‍👧test", 2)

20 '👨\u200d👩\u200d👧t'

21"""

22

23# Public API exports

24 import unicodedata

25

26 from . import invisibles, segments, spoofing

27 from ._exceptions import IndiumError, InvalidTextError, TruncationError

28

29# Import commonly used functions to top level

30 from .invisibles import count_by_category, detect_invisibles, reveal, sanitize

31 from .segments import count_graphemes, grapheme_slice, iter_graphemes, safe_truncate

32 from .spoofing import detect_confusables, get_script_blocks, is_mixed_script, skeleton

33

34 __version__ = "1.0.0"

35 unicode_version = unicodedata.unidata_version

36

37 __all__ = [

38 # Metadata

39 "unicode_version",

40 # Modules

41 "invisibles",

42 "spoofing",

43 "segments",

44 # Exceptions

45 "IndiumError",

46 "InvalidTextError",

47 "TruncationError",

48 # invisibles functions

49 "reveal",

50 "sanitize",

51 "detect_invisibles",

52 "count_by_category",

53 # spoofing functions

54 "skeleton",

55 "is_mixed_script",

56 "get_script_blocks",

57 "detect_confusables",

58 # segments functions

59 "safe_truncate",

60 "count_graphemes",

61 "grapheme_slice",

62 "iter_graphemes",

63]