feat(08): implement SSOT architecture for network configuration

This commit is contained in:
2026-04-23 13:58:33 +03:00
parent 5978917494
commit a5a460e765
1039 changed files with 138862 additions and 105259 deletions

View File

@@ -1,6 +1,7 @@
import bisect
import re
import unicodedata
import warnings
from typing import Optional, Union
from . import idnadata
@@ -166,7 +167,7 @@ def valid_contextj(label: str, pos: int) -> bool:
ok = False
for i in range(pos - 1, -1, -1):
joining_type = idnadata.joining_types.get(ord(label[i]))
joining_type = idnadata.joining_types().get(ord(label[i]))
if joining_type == ord("T"):
continue
elif joining_type in [ord("L"), ord("D")]:
@@ -180,7 +181,7 @@ def valid_contextj(label: str, pos: int) -> bool:
ok = False
for i in range(pos + 1, len(label)):
joining_type = idnadata.joining_types.get(ord(label[i]))
joining_type = idnadata.joining_types().get(ord(label[i]))
if joining_type == ord("T"):
continue
elif joining_type in [ord("R"), ord("D")]:
@@ -337,25 +338,20 @@ def uts46_remap(domain: str, std3_rules: bool = True, transitional: bool = False
for pos, char in enumerate(domain):
code_point = ord(char)
try:
uts46row = uts46data[code_point if code_point < 256 else bisect.bisect_left(uts46data, (code_point, "Z")) - 1]
status = uts46row[1]
replacement: Optional[str] = None
if len(uts46row) == 3:
replacement = uts46row[2]
if (
status == "V"
or (status == "D" and not transitional)
or (status == "3" and not std3_rules and replacement is None)
):
output += char
elif replacement is not None and (
status == "M" or (status == "3" and not std3_rules) or (status == "D" and transitional)
):
output += replacement
elif status != "I":
raise IndexError()
except IndexError:
uts46row = uts46data[code_point if code_point < 256 else bisect.bisect_left(uts46data, (code_point, "Z")) - 1]
status = uts46row[1]
replacement: Optional[str] = None
if len(uts46row) == 3:
replacement = uts46row[2]
if status == "V" or (status == "D" and not transitional) or (status == "3" and not std3_rules and replacement is None):
output += char
elif replacement is not None and (
status == "M" or (status == "3" and not std3_rules) or (status == "D" and transitional)
):
output += replacement
elif status == "I":
continue
else:
raise InvalidCodepoint(
"Codepoint {} not allowed at position {} in {}".format(_unot(code_point), pos + 1, repr(domain))
)
@@ -370,6 +366,13 @@ def encode(
std3_rules: bool = False,
transitional: bool = False,
) -> bytes:
if transitional:
warnings.warn(
"Transitional processing has been removed from UTS #46. "
"The transitional argument will be removed in a future version.",
DeprecationWarning,
stacklevel=2,
)
if not isinstance(s, str):
try:
s = str(s, "ascii")

File diff suppressed because it is too large Load Diff

View File

@@ -1 +1 @@
__version__ = "3.11"
__version__ = "3.13"

File diff suppressed because it is too large Load Diff